My Git flow consists of develop, master and feature branches. I use Alembic for database migrations, and I run migrations only after merging branches into master.
Currently, merging a branch containing migrations into develop causes trouble. Here is the problematic process:
New branch off of develop (BRANCH 1)
Create migrations in BRANCH 1
Merge BRANCH 1 into develop
The migrations aren't being run because they are not in master
Another new branch off of develop for a different feature (BRANCH 2)
Now, it's impossible to create migrations in BRANCH 2 - I get Target database is not up to date because the head revision is the new revision created in #1, but the database has not been upgraded yet.
Running alembic history gives:
c4892151a825 -> 3451e691af8a (head), BRANCH 1
c4a0d473218e -> c4892151a825, MASTER MIGRATIONS
What I'm trying to achieve is to have the two migrations run sequentially:
c4892151a825 -> 3451e691a4jf BRANCH 2
c4892151a825 -> 3451e691af8a BRANCH 1
... -> c4892151a825, (head), MASTER MIGRATIONS
I tried running alembic revision --head c4892151a825, but it says that the revision is not a head revision.
I found a temporary solution:
move BRANCH 1 migration file to a different location
Create a new revision.
Return the migration file to the previous location and merge the two using alembic merge.
Related
Hi every body I'm learning Symfony 5, on migrations lessons, after a lot of make:migration commands, this time I've this messageenter image description here
And on doctrine:migrations:migrate command, I've this error
enter image description here
But in my migrations file , there's a migration with create etudiant table.
So I'll know how to run that one migration for having that table in my database, Thanks!
This Error often happened when you got some differents between the last migration file and your BDD.
First of all your script seems to drop 'etudiant' table but this one does not exist. May be you have drop it before.
However you have many possibility :
You can delete all migration file on your symfony project (under migrations folder), then delete all sql entry on doctrine_migration_versions.
After that you can redo your migration command line (make:migration and doctrine:migrations:migrate).
You can edit the last migration file on your symfony projet and delete the drop table in trouble.
Basically I have two branches, main and branchA. In branchA I add sql files, so that GIT tracks their changes. But when I merge this branch back to main, I want the main branch to ignore all sql files. Basically, I don't want the main branch to even have sql files committed, since they should only exist as development aids. Is this possibly?
After committing the sql files in your branch A, you can add these files in gitignore and commit it.Or, in main branch, you can execute the following git command to ignore these file changes:git update-index --no-assume-unchanged
I am complete Noobie in Liquibase (and jenkins) deployments.
We have a SQL table which can be modified by 2 separate git repositories. We have one liquibase based deployment for this table for each of the git repos.
ISSUE:
Liquibase will try to update the DATAGBASECHANGELOG after each deployment. Thus breaking the cycle of continuity between 2 commits in the same git repo.
E.g.
We have a table A, the script for which is A.sql and it is in two repos X and Y. The table script can be modified in either of the two repos X or Y. Now if I do the first deployment using the repo X, second using repo Y and then change the file A.sql in repo X, then next repo X deployment with fail because of mismatched changesets.
What we think can solve this is that we need to have 2 different DATABASECHANGELOG tables for each repository deployment?
Any help or pointers will be of great help.
I have just started testing migrations in several different team scenarios to make sure migrations will work as expected with git / multiple users / multiple branches. But I have run into an issue right off the bat. On branch 1 I added my Initial migration (on an existing project with 165 entities), deleting the code in Up/Down (just uses the model snapshot), then update-databased (creates the __MigrationHistory table just fine). I merge this to branch 2 (EXACTLY the same model – exact replica of branch 1), ran update-database with my newly merged migrations and it says Unable to update database to match the current model because there are pending changes. There aren’t pending changes, both models are exactly the same. Is there something I am missing here? I thought I should only run into this issue once migrations are out of whack (merge, model changes from different users).
So why must I do add-migration Initial on both branch 1 and branch 2? They are merged and exactly the same.
Notes: EF 5 (technically 4.4) with .NET 4.0. DevArt dotConnect for Oracle v 8.1.55.0
EDIT: I have read this post but I am not on different platforms, I'm on the same computer - just different branches.
I figured it out, in my initial testing of moving off of EDMX to dotConnect code-first + migrations, I added the schema to the _Mapping files for my fluent mappings. I had to remove this schema. Example:
Instead of:
this.ToTable("ADDRESS", "SCHEMA");
I had to use:
this.ToTable("ADDRESS");
Also I use these options in OnModelCreating:
var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
config.Workarounds.IgnoreDboSchemaName = true;
config.Workarounds.IgnoreSchemaName = true;
I have a minor issue which force me to introduce a new migration in between two migrations.
Short version of my question is: whether it is safe to introduce a new migration between previous two.
What I did
I need to have a table which will be filled from a file.
I added a table then imported data on the table by two migrations:
A migration which create a table with named ID column by using self.primary_key = some_id
A migration to import text data onto the table
The issue was, I forgot to add :id => false to the first migration. This cause id column to be created but haven't set correctly. Since I have primary key in some_id it does not cause problem up to now.
Rails 3.2.4
Now, I upgraded to Rails 3.2.4. Due to the change, it look like I need to set unique id before save. Which cause migration 2 above to fail.
The easiest fix is removing id column between above two migrations because I need test suite to build the database from scratch time to time. To make the import to work, I need to fix it before 2nd migration run.
Question
Now the question.
Since above migrations are deployed already, The migration will run after all of the migrations other than the one.
In my case, it looks like Ok to create such a migration (with timestamp in between above two).
Is it okay to do add migration like this way, in this case?