Questions tagged [doctrine-migrations]

Anything related with Doctrine migrations for Symfony and DoctrineMigrationsBundle library

Doctrine migrations for Symfony are maintained in the DoctrineMigrationsBundle.

The database migrations feature is an extension of the database abstraction layer and offers you the ability to programmatically deploy new versions of your database schema in a safe, easy and standardized way.

139 questions
26
votes
1 answer

How to stop Doctrine2 Migrations:Diff from always adding foreign key relationships that already exist in Database?

I'm using doctrine2 with a symfony2.1 project. I have an entity that has a few many to one relationships to other tables. The foreign key relationships for these many-to-one's have already been updated in the database, but every time I run…
cjewby
  • 383
  • 3
  • 6
19
votes
1 answer

How do I write a Doctrine migration which can redistribute data into new tables

I have a database (which was actually created using Propel in a Symfony1 application). I am reimplementing it in Symfony2 and Doctrine, but I also want to take the opportunity to refactor the database somewhat. I have defined a set of Doctrine…
Colin Fine
  • 3,334
  • 1
  • 20
  • 32
16
votes
2 answers

Execute next / previous migration with doctrine migrations using symfony 3

I know that I can run specific migrations using execute with up / down and version number, ie doctrine:migrations:execute YYYYMMDDHHMMSS --down My question then - is there an easier way to simply run the next or previous migration without having to…
Bananaapple
  • 2,984
  • 2
  • 25
  • 38
14
votes
3 answers

Run a database migration command when deploying a Docker container to AWS

Please bear with me. Pretty new to Docker. I'm deploying Docker containers (detached) to an AWS EC2 registry using CodeDeploy. On deploy, the following command is run after setting some environmental variables etc: exec docker run -d ${PORTS} -v…
Fredrik
  • 1,741
  • 4
  • 24
  • 40
12
votes
1 answer

Prevent Doctrine migration diff from deleting tables

I'm currently in the process of "Doctrinizing" an large existing database. This process is working very well and we're slowly able to substitute the old raw query code with entities and DQL. We recently discovered the awesome Doctrine Migrations…
Luke
  • 20,878
  • 35
  • 119
  • 178
10
votes
1 answer

Rename table name with Doctrine migrations

I've searched pretty much everywhere but I wasn't able to find anything. Is there a command or a procedure to change the name of a table (so inside doctrine annotation) without loosing data? Basically, something that will produce something…
DonCallisto
  • 29,419
  • 9
  • 72
  • 100
9
votes
1 answer

Doctrine migrations:diff regenerates same unique index constraint

I have a weird problem. When I run doctrine-migrations migrations:diff it regenerates the index that already is set in an earlier migration. Earlier migration (the uniq index is also present in my database): $this->addSql('CREATE TABLE my_table (id…
user7429559
9
votes
2 answers

How to test Doctrine Migrations?

I'm working on a project that does NOT have a copy of production DB on development environment. Sometimes we have an issue with DB migrations - they pass on dev DB but fail in production/testing. It's often beacuse Dev environent data is loaded from…
paq85
  • 864
  • 10
  • 13
8
votes
3 answers

Doctrine migrations always generates empty up() and down() migration with collate change to 'utf8mb4_unicode_ci'

When I run php bin/console doctrine:migrations:diff I always get the following newly generated migration:
8
votes
4 answers

Syntax error or access violation: 1064 You have an error in your SQL In symfony

When i run comand php bin/console doctrine:migration:migrate i got this error I don't know where is come from. command line error : In AbstractMySQLDriver.php line 99: An exception occurred while executing 'CREATE TABLE user (id INT AUTO_INCREMENT…
Abdo Abo
  • 93
  • 1
  • 2
  • 13
8
votes
2 answers

phpstan complains about Doctrine Migrations in Symfony 3.4 with Flex project

I have a project built on Symfony 3.4 with Flex and I've added phpstan to it for static analysis. It is complaining about not finding my migration classes: Class DoctrineMigrations\Version20180831185050 was not found while trying to analyse it -…
Radu C
  • 1,340
  • 13
  • 31
8
votes
1 answer

Doctrine Migrations Namespace Error

I am trying to setup doctrine migrations on top of silex framework. I installed it through composer. "doctrine/dbal": "2.3.*", "doctrine/migrations": "dev-master", My console file: ... $app['composer_loader']->add('Doctrine\DBAL\Migrations',…
dextervip
  • 4,999
  • 16
  • 65
  • 93
7
votes
4 answers

Doctrine Migration class not found error when attempting to run down/rollback command

When I run bin/console doctrine:migrations:list I see the Migration listed as: Application\Migrations\Version20210909072642 I am attempting to rollback a migration and I have tried a few different versions: bin/console --env=dev…
crmpicco
  • 16,605
  • 26
  • 134
  • 210
7
votes
0 answers

Doctrine migrations: cannot insert multiple commands into a prepared statement

I am trying to prepare first migration for project, that has quite big postgres database. I have dumped production DB schema, cleared it from comments and empty lines, and put whole as a text in single variable. Then I called…
Fisher
  • 1,712
  • 1
  • 19
  • 38
7
votes
4 answers

Symfony 4: how to safely 'join' migrations together? / remove migrations in between the first and last?

I was recently tweaking around with my DB and noticed that I made 5 migrations on top of my existing 2. So 7 in total, m1, m2, ..., m7. From these 5, I only want the latest version. So I was thinking I could remove m3, m4, m5, m6, m7 and migrate…
user8678484
1
2 3
9 10