Detected resolved migration not applied to database on flyway - database

We are using flyway to manage database schema version and we are facing a problem. Since we work as a team and use git as our source code management, there would be some cases that different people update database schema on their own local repo. If that happens, we will get
Detected resolved migration not applied to database: 2016.03.17.16.46"
The time "2016.03.17.16.46" was added by another person and I have already applied some timestamp later than that time. If that happens, we have to clean all database tables and create them again. We have tried to set false on validateOnMigrate and did flywayClean, but nothing help. Is there another way to change that?

The migration option outOfOrder is your friend here. Set it to true to allow inserting those migrations after the fact.
On the command line, run:
flyway -outOfOrder=true migrate
Or if you use the Maven plugin:
mvn -Dflyway.outOfOrder=true flyway:migrate

I faced similar problem when switching from one git branch to another and tried to run
flyway:migrate.
For example when I was on branch 'release_4.6.0' I didn't have migrations on my local machine from branch 'release_4.7.0' so
I received next error
FlywayException: Validate failed: Detected applied migration not resolved locally.
The solution that worked for me is to set ignoreMissingMigrations flyway option to true.
In maven it looks like
flyway:migrate -Dflyway.ignoreMissingMigrations=true
Maybe it's not an answer for this question, but it can be helpful for those who faced the same problem as me.
Here you can find more details:
https://flywaydb.org/documentation/configuration/parameters/ignoreMissingMigrations

You can also put it in your application.properties file if you want to apply the migrations when starting up the app:
spring.flyway.out-of-order=true

just add spring.flyway.ignore-missing-migrations=true
to your properties file if you are using spring-boot.
This will ignore previous migrations.

outOfOrder did not fix the problem for us.
Two migrations slipped into one deployment before it got removed.
So we added those migrations back in and undid the changes in another migration.
Worked 🤷

In my case, I just renamed my migration file to some other name and then renamed it back – just to update modification date of the file. And it worked.

In my case, there was existing a row with version 319 in database and the correponding file for 319 was renamed do 330, so the database registry could not find the corresponding file. Deleting the row from database solved the problem.

Since spring.flyway.ignore-missing-migrations=true became deprecated.
According to the docs I advise using spring.flyway.ignore-migration-patterns=*:missing. Or in the yaml:
spring:
flyway:
ignore-migration-patterns:
- "*:missing"

Related

CiviCRM "database looks to have been partially upgraded"

I recently upgraded both Drupal and CiviCRM to the latest versions. Drupal works fine, and so does Civi except when I move to the Civi menu, I get a message that says "Database check failed - the database looks to have been partially upgraded. You may want to reload the database with the backup and try the upgrade process again." This happened earlier and reloading the most recent backup didn't help. We had to go back quite a ways before we found one that did, then had to reload a lot of data from .CSV files and by hand. I'd rather not go through with that again.
One thing we found when comparing the development site on my WAMP desktop (which was a new install that works well) with the one on my ISP's server is that the server version contained two MyISam-format files from, or generated by, CiviCase where Civi wants to see InnoDB-format files. My ISP, far more knowlegable than I am about MySQL, converted these two files two InnoDB and the problem remains. This leaves me with two questions:
could the MyISam files be the source of the "incomplete upgrade"? and
is there some way to reset a flag that tells Civi that the database is incomplete or to run the database check manually?
Thanks for any help. Civi seems to work OK as is, but the error message will be disturbing to my end users.
That message happens when you have begun the CiviCRM database upgrade but it hasn't finished. CiviCRM edits the version number in the civicrm_domain table to flag that you're in the middle of an upgrade, and when the upgrade completes, it should remove that.
The simple way to remove the message is to go edit that in the database, but it gets set there for a reason: your database upgrade never completed.
You should restore everything to the last version where it all was working--restore both the code and the database. Play around for a bit and make sure nothing funny is happening.
Run a normal CiviCRM upgrade, replacing the files and running the upgrade script. Take note of anything that seems funny when the upgrade script runs. You might try doing a minor upgrade--just a point release--simply to be sure that any upgrade is working fine.
At this point, you should either have no problems or a much more detailed problem.
Finally, please note that there is now a CiviCRM-specific StackExchange site, which is where you'll find the most CiviCRM experts to answer your questions.

How to update a special package only?

When run Pkg.update(), all package will be updated if it is not pinned or dirty.
But it is possible to update a special package(such as FackCheck)?
I have taken a little look on the Julia source code, but haven't fond the direct solution.
I know I can pin all packages and when want to update someone, just unpin the package then run Pkg.update(), but I think it is not a good way.
You can also navigate to the package directory and type git checkout master && git pull. You can say Pkg.free("SomePackage") when you want to go back to having the package manager take charge of it.
If you know which package version you want to use you can do something along these lines.
Pkg.rm("FactCheck")
Pkg.add("FactCheck", v"0.1.1")
But that will also fix FactCheck at that version so a Pkg.update() will ignore it.
The slightly more crude and manual variant would be:
Goto https://github.com/JuliaLang/METADATA.jl/
Search the Pacakge you want and the latest version
In the case of Factcheck that would be https://github.com/JuliaLang/METADATA.jl/tree/metadata-v2/FactCheck/versions/0.1.2
Now copy the value in sha1 file
cd ~/.julia/v0.3/FactCheck
git checkout $sha1 .
But in this case you might be missing potential requirements.
So assuming that what you wan is not a specific version but the master branch for the bleeding edge version you can simply do.
Pkg.rm("FactCheck")
Pkg.clone("FactCheck")
But now you are working with a potential unstable version.
So in the end the question is what specific use case do you have that warrants only updating one package. If you only update one package that might cause dependency issues so updating all packages simultaneously is the better option.

How to use Minion Task Migrations for Database Migrations

I am running Kohana 3.3 and wanting to add database migrations to my project.
I have added the following moulde https://github.com/kohana-minion/tasks-migrations but not sure how to get it working.
I can see the help file running ./minion migrations:new --help but I don't understand what group value is required. From the docs it says:
--group=group_name
This is a required config option, use it specify in which group the
migration should be stored. Migrations are stored in a `migrations`
directory followed by the group name specified. By default, the `migrations`
directory is created in `APPPATH` but that can be changed with `--location`
--location=modules/auth
Specified the path of the migration (without the `migrations` directory).
This value is defaulted to `APPPATH`
# The migration will be created in `modules/myapp/migrations/myapp/`
--group=myapp --location=modules/myapp
--description="Description of migration here"
This is an arbitrary description of the migration, used to build the
filename. It is required but can be changed manually later on without
affecting the integrity of the migration.
I've been searching for examples but yet to find one. I have an existing database, so I would like to grab the schema from that as my base and then run further migrations after. Is this how tasks-migrations module works?
The group method is used to tell you what kind of migrations it are. If it are migrations of your core application then the group core would be suitable.
But maybe you build yourself a module for your application that had it's own tables and thus its own migrations. thus it would be better to use the group module_name.
This way you can split your migrations in more suitable parts and are able to easily check only the migrations of your modules without having to search through all other migrations.
Make new migrations
./minion migrations:new --group=core
Run migrations
./minion migrations:run
PS: Dont forget to add the migrations table to the database
The group was the migration version number e.g.
./minion migrations:new --group=0-1
Created a folder and migration file in application/migrations/0.1 with the up and down methods.

Empty my Sqlite3 database in RoR

I am working on a Ruby on Rails 3 web application using sqlite3. I have been testing my application on-the-fly creating and destroying things in the Database, sometimes through the new and edit actions and sometimes through the Rails console.
I am interested in emptying my Database totally and having only the empty tables left. How can I achieve this? I am working with a team so I am interested in two answers:
1) How do I empty the Database only by me?
2) How can I (if possible empty) it by the others (some of which are not using sqlite3 but MySql)? (we are all working on an the same project through a SVN repository)
To reset your database, you can run:
rake db:schema:load
Which will recreate your database from your schema.rb file (maintained by your migrations). This will additionally protect you from migrations that may later fail due to code changes.
Your dev database should be distinct to your environment - if you need certain data, add it to your seed.rb file. Don't share a dev database, as you'll quickly get into situations where other changes make your version incompatible.
Download sqlitebrower here http://sqlitebrowser.org/
Install it, run it, click open database (top left) to locationOfYourRailsApp/db/development.sqlite3
Then switch to Browse data tab, there you can delete or add data.
I found that by deleting the deployment.sqlite3 file from the db folder and inserting the command rake db:migrate in the command line, it solves the problem for all of my team working on sqlite3.
As far as I know there is no USER GRANT management in sqlite so it is difficult to control access.
You only can protect the database by file access.
If you want to use an empty database for test purpose.
Generate it once and copy the file somewhere.
and use a copy of this file just before testing.

Joomla! Quickstart package manual

I made some custom template and I still struggling with the most significant problem, how could I make a quickstart?
All the information what I found, doesn't helped me, including (http://www.youtube.com/watch?v=nqG6Z8nhyBU), which is briefly:
Copy the designed database
Delete configuration.php from copied root
Copy default Joomla! Installation folder to copied root
Export sql.file from original database to copied installation/sql/msql
Rename that to sample_data.sql
Upload whole content to the server
Install as a usual Joomla! site
All the time I getting:
Error: the XML response that was returned from the server is invalid.
in this reason I have to skip this message) when I select install sample data in my Joomla! pack installation. My template not appears as deafult and the places of module postions these are messages for e.g:
Warning: DB reports: DB function failed with error number 1146
Table 'masolat.jos_sobi2_language' doesn't exist SQL=SELECT * FROM jos_sobi2_language ORDER BY sobi2Lang in C:\wamp\www\masolat\components\com_sobi2\config.class.php on line 2534
...and so on.....
So prorbaly the whole process that I've made is false. That's why I would like ask you some help.
Have you any idea, how can I accomplish without any kind of Joomla! copy/restore extension?
Short guide, review, link, explanation will be appreciated.
Thank you in advance!
Regards: Nehogymar
There are two ways that you can install Joomla, the way that you described or the easy way for non-programmers.
Try to install joomla the easy way, There is very good explanation in Joomla documentation. try: http://help.joomla.org/content/view/39/132
There is also a excellent guide for installing Joomla on WAMP:
http://www.compassdesigns.net/joomla-tutorials/how-to-install-joomla-15
The simple way to make a copy of a Joomla website to install is to use Akeeba Backup. It makes a nice ZIP package with all of the files, settings, and database with a nice install script. I have a base install with all of the extensions I use to speed up configuration time.
http://extensions.joomla.org/extensions/access-a-security/site-security/backup/1606

Resources