-
Notifications
You must be signed in to change notification settings - Fork 4
Doctrine
Makes from entities the database structure. https://symfony.com/doc/5.4/doctrine.html
Status:
-
bin/console doctrine:migrations:statusshows status of the migrations
Create and apply migrations for changes:
-
bin/console make:migrationsymfony manner doesdoctrine:migrations:difffor making a migration file. -
bin/console doctrine:migrations:diffcreate a database migration from the differences between entity mapping and database. Check the generated class. Especially if existing data should be moved/converted extra work is typically needed. -
bin/console doctrine:migrations:migrateThis command executes all migration files that have not already been run against your database. You should run this command on production when you deploy to keep your production database up-to-date. -
bin/console doctrine:migrations:executerun a single migration -
bin/console doctrine:migrations:migrate prevgo to previous version, so uses down part of a migration Validate: -
bin/console doctrine:schema:validateto validate the entity mapping is correct and in sync
Make migration for existing database or combine all previous migration in one:
Assumes that production is up-to-date.
-
bin/console doctrine:migrations:diff --from-empty-schemawill generate a full migration as if your database was empty. You can then use the rollup command to synchronize the version table of your (already up-to-date) database. (note: do not use dump-schema, its output is based on the database not on the entities) -
bin/console doctrine:migrations:rollupdelete old versions from the database and replace it with the last one. Run this also on production, to reset the version table there. Execution of the one, new, migration is not needed at production because the database should be already up to date. Works only if there is one version in the migrations directory.
Query directly
Results of selects are automatic listed. For listing of results of other sql commands add the --force-fetch option.
php bin/console dbal:run-sql 'SELECT * FROM repository'php bin/console dbal:run-sql 'SHOW TABLES' --force-fetchphp bin/console dbal:run-sql 'DESC repository' --force-fetch
Other:
-
bin/console doctrine:database:dropdrops the database -
bin/console doctrine:database:createcreates the database -
bin/console doctrine:schema:updatedumps the difference between entities and database. Is used inbin/console doctrine:migrations:diff. Does not take care of existing data, therefore, in development environment that should be tested and included in the migrate class. -
bin/console doctrine:migrations:generatecreates empty Migration class which you can fill yourself
Backup
mysqldump -u translate -p translate > translate_db_backup_20230414.sql- or sometimes:
mysqldump -u translate -p --no-tablespaces translate > translate_db_backup_20230414.sql
More readings:
Process
- Translation process
- CronJob overview triggers some commands.
- Commands for regular tasks and occasional maintenance
Files
Maintenance/development
- Deploying to Production is done from GitHub
- Development setup
- Maintenance
- Alternative Git interaction when setting up development setup
- Test steps for checking working of the tool
Documentation
- Components of Symphony used for the Tool
- More detail about using Doctrine
- Description working of the Forms