When creating a second migration and attempting to migrate up to add it, the task fails because the first migration was already run. It seems to be running (and failing) rather than skipping previously successful/complete migrations.
I have tried with --no-check-order but I don't want to do that everytime I got new migrations to add.
I have my database locally.
Using node-pg-migrate and postgreSQL
In a general way, the order of migrations matters as you can e.g. alter the same type and the last run migration wins.
It can happen e.g. if you have pull requests and merge them to base branch in a different order than the migrations were created.
You can now e.g. rename migration so it is sorted on disk in the correct order (before not-run-migrations) and update records in pgmigrations table, or you can put new migrations aside (so they do not trigger this error) and run as many down migrations as needed, then restore migrations definitions on disk and run up migrations.
Related
I am using prisma with data pipeline. i am fetching data from different database and create new portal with few changes in database. Database can also change in production time, i don't want to lose ant data from data factory. is it possible to run migration without cause data lost.
You have to use prisma migrate resolve in order to ignore some migrations before running prisma migrate deploy, here you go more information
I am struggling with a problem connected with the migrations in knex on the production environment (heroku). I have made some changes and created 8 new migrations to update the model. After creating new migrations I have reached 47 migration files. After uploading the changes to the Heroku I executed as usual knex migrate:latest and there was no effect. I have received the message Already up to date.
I have decided to take a look at the knex_migrations table to see if maybe something is wrong there. The result that I can see that the new migrations were not written into that database (please see the picture for reference.
When we take a look at the migrations it looks like this:
Clearly we can see that knex was able to run "20200216191040_receiver_company.js" as last one.
When I take a look at the knex_migrations_lock table the only entry that is existing over there looks like this:
Does anyone know how to force knex to run the migrations? The version of knex that I use it 0.16.3.
EDIT:
I want to add that on the local machine I have no problems with running the migrations. Additionally, I have checked if the migration files are present on the server and after pulling the current state our of the Heroku I can see all of the migration files that were not executed.
If the change of the migration is not implemented in the database, you can try to manually remove the record of the migration from the knex_migrations or you migrations table,
and try to re-apply the knex migrate:latest command.
but before you try this way, make sure to keep a backup, or run it on your local machine or development server first.
for the first time I updated an app with the jhipster upgrade command.
It seems all ok but at the end of the updating it noticed me about three conflicts that I have to resolve manually.
My first problem is: how to update the Liquibase scripts?
In this case, have been added some uniqueConstraintName but I can't to add them in my scripts because they have already been executed.
So, which is the best solution? Don't update the scripts? Mark them as merged? Add manually another script in order to add these constraints?
And how I have to solve other conflicts like the image below?
Simply copy and paste from new file to old file?
Thanks a lot,
Andrea
If you have a live database, then you must not upgrade your liquibase scripts but add new ones to do the migration. What you can do is running the new scripts against a blank dev database (same type of db as prod), then revert to old scripts, then call ./mvnw liquibase:diff to get the delta script, then add the delta script to the scripts to run.
Consider the following deployment workflow, where staging and product use the same database:
Deploy application to Azure Website staging slot
Run EF code first migrations in staging (updating the shared database)
Test application in staging
Swap endpoints so that what was deployed to staging is now in the production slot
This process worked for a few releases, but today it didn't. The issue is around migrations ran in the Staging slot against the same database as the Production slot. We're every careful to not rename or remove any columns that would break production between steps 2 and 4. Today's migrations included a new foreign key and a script to create some tables for a forum control (there are no entities for these new tables, it's managed entirely by a third party control - we only added the migration so that we didn't have to manually run the install script).
We got the standard AutomaticMigrationsDisabledException below in the production slot after step 2.
System.Data.Entity.Migrations.Infrastructure.AutomaticMigrationsDisabledException:
Unable to update database to match the current model because there are
pending changes and automatic migration is disabled. Either write the
pending model changes to a code-based migration or enable automatic
migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to
true to enable automatic migration.
Is there a list of known changes that cause this exception? Or are migrations just not designed to be used this way?
We've also considered something like what SO does, but we'd rather not recreate the wheel if we don't have to.
In my Orchard project, I used both SQL command (to get data) and repository method (to update data).
But they don't work together:
Step 1: I uses SQL command to get data.
Step 2: uses repository() to update these data.
Step 3: uses SQL command to get updated data.
When step 3 was called, the database become hanging.
It's may be because repository() is still holding database after updated data, therefore SQL command must wait until repository releases the database.
So, how to force repository releases updated database right after it finished its work ?