Regarding FlywayDB Issue - flyway

I am using flyway db version 6.0.8 in my local macbook pro with MySQL Database Integration.
I have placed a create table script under ~/sql and using below command to migrate. However its not creating table its only creating "flyway_schema_history" but not the actual table.
Conf file:
flyway.user=flyway
flyway.url=jdbc:mysql://127.0.0.1:3306/db
Below are the flyway logs:-
Flyway Community Edition 6.0.8 by Redgate
Database: jdbc:mysql://127.0.0.1:3306/DB (MySQL 8.0)
Successfully validated 0 migrations (execution time 00:00.005s)
Creating Schema History table `db`.`flyway_schema_history` with baseline ...
Successfully baselined schema with version: 1
Current version of schema `db`: 1
Schema `db` is up to date. No migration necessary.```

Flyway follows the simple path. And that is convention.
When creating Flyway migration file or even locating it, you have to follow conventions.
For example, the path cannot be some random folder:
Also the naming:
The file name consists of the following parts:
Prefix: V for versioned (configurable), U for undo (configurable) and R for repeatable migrations (configurable)
Version: Version with dots or underscores separate as many parts as you like (Not for repeatable migrations)
Separator: __ (two underscores) (configurable)
Description: Underscores or spaces separate the words
Suffix: .sql (configurable)
Resource : https://flywaydb.org/documentation/migrations

If you run flyway with the -X parameter, it will print out the locations it is searching for migrations.
e.g.
flyway migrate -X
This should help you figure out where it is searching, vs where you have put your migration files.

Related

Change `wp db export` default database name

Is there a way to change what the database is named when using the wp db export command?
When I type wp db export on one of my WordPress sites, the database gets named {dbname}-{Y-m-d}-{random-hash}.sql, which is correct according to WP-CLI Commands. When I run the same command on one of my other sites, it names the db dbname.sql (which I prefer).
Is there a way I can have wp db export name the exported db dbname.sql?
I know I can type wp db export dbname.sql but I just wanted to see if the default when typing wp db export could be modified.
You are probably using different versions of WP-CLI on both machines. Up until version 1.2.0 the default was just {dbname}.sql. Since version 1.2.1 it defaults to {dbname}-{Y-m-d}-{random-hash}.sql.
Verify the WP-CLI versions with
wp --version
There is no way to override the default itself other than you just did by passing it a filename. But there still is a way to get the database name dynamically and then name the file after it by using the --porcelain option to only get the filename and then chain two wp db export commands together like that:
# Exports the database named '{dbname}.sql'.
wp db export $(wp db export --porcelain | cut -f1 -d "-").sql
cut -f1 -d "-" cuts the porcelain output with the first -. Since databases can't have dashes in their name, this seems a pretty save method to be used on your system with the newer WP-CLI version.
To have one command to be used on both your machines, you may need to find a way to check for the existence of - characters first, and cut only if a - exists. Or install a WP-CLI lower than version 1.2.1 on both machines.

When I hit ./iiq console in command prompt my Sailpoint says database version doesn't match the system version

I'm trying to run the training modules in sailpoint, where I was following the exercises. I was able to set up the database and all. When I try to run the Identityiq console, using ./iiq console, it flashes the error, the database version and the system version do not match. How do I change the versions to make them match?
I tried changing the schema version to the system version, but it doesn't match as it was checking database version and system version.
in the bin directory, i used the command
$./iiq console
This was the result: System version 6.1-64 doesn't match database version 6.2-32 Attached
Try to run command : iiq patch 6.2
There are two options here
Either install the patch for 6.2
Drop the database and run the database scripts from the web-inf/database folder.

Capifony deploy runs some commands against previous release

I'm running a Capifony deployment. However, I notice that Capifony's in-built commands are running against the previous release, whereas my custom commands are correctly targeting the current release.
For example, if I run cap -d staging deploy, I see some commands output like this (linebreaks added):
--> Updating Composer.......................................
Preparing to execute command: "sh -c 'cd /home/myproj/releases/20130924144349 &&
php composer.phar self-update'"
Execute ([Yes], No, Abort) ? |y|
You'll see that this is referring to my previous release - from 2013.
I also see commands referring to this new release's folder (from 2014):
--> Running migrations......................................
Preparing to execute command: "/home/myproj/releases/20140219150009/
app/console doctrine:migrations:migrate --no-interaction"
Execute ([Yes], No, Abort) ? |y|
In my commands, I use the #{release_path} variable, whereas looking at Capifony's code, it's using #{latest_release}. But obviously I can't change Capifony's code.
This issue against Capistrano talks about something similar, but I don't think it really helps, as again I can't change Capifony's code.
If I delete my releases folder on the server, I have a similar problem - #{latest_release} doesn't have any value, so it attempts to do things like create a folder /app/cache (since the code is something like mkdir -p #{latest_release}/app/cache).
(Assuming I don't delete the current symlink and the release folder, the specific error I see is when it fails to copy vendors: cp: cannot copy a directory, /home/myproj/current/vendor, into itself. However, this is just the symptom of the bigger problem - if it thinks the new release is actually the previous one, that explains why current also points there!)
Any ideas? I'm happy to provide extracts from my deploy.rb or staging.rb (I'm using the multistage extension) but didn't just want to dump in the whole thing, so let me know what you're interested in! Thanks
I finally got to the bottom of this one!
I had a step set to run before deployment:
before "deploy", "maintenance:enable"
This maintenance step (correctly) sets up maintenance mode on the existing site (in the example above, my 2013 one).
However, the maintenance task was referring to the previous release by using the latest_release variable. Since the step was running before deployment, latest_release did indeed refer to the 2013 release. However, once latest_release has been used, its value is set for the rest of the deployment run - so it remained set to the 2013 release!
I therefore resolved this by changing the maintenance code so that it didn't use the latest_release variable. I used current_release instead (which doesn't seem to have this side-effect). However, another approach would be to define your own variable which gets its value in the same way as latest_release would:
set :prev_release, exists?(:deploy_timestamped) ? release_path : current_release
I worked out how latest_release was being set by looking in the Capistrano code. In my environment, I could find this by doing bundle show capistrano (since it was installed with bundler), but the approach will differ for other setups.
Although the reason for my problem was quite specific, my approach may help others: I created an entirely vanilla deployment following the Capifony instructions and gradually added in features from my old deployment until it broke!

Aegir-up (Aegir+Vagrant+Drush) setup

I am trying to establish a proper Drupal development environment by using Aegir-up (Vagrant-based Aegir virtual machine). I will illustrate how I follow the following "Quick start" steps and fail:
Install dependencies, including drush-vagrant and drush-hosts:
C:\Users\Domas>drush dl drush-vagrant drush-hosts
Install location C:\Users\Domas/.drush/drush-vagrant already exists. Do you want to overwr
ite it? (y/n): y
Project drush-vagrant (7.x-2.0-beta6) downloaded to [success]
C:\Users\Domas/.drush/drush-vagrant.
Project drush-vagrant contains 0 modules: .
Install location C:\Users\Domas/.drush/drush-hosts already exists. Do you want to overwrit
e it? (y/n): y
Project drush-hosts (7.x-1.1) downloaded to C:\Users\Domas/.drush/drush-hosts. [success]
Project drush-hosts contains 0 modules: .
I don't know if "contains 0 modules" is significant. I attempt installing aegir-up:
C:\Users\Domas>drush dl aegir-up
Install location C:\Users\Domas/.drush/aegir-up already exists. Do you want to overwrite i
t? (y/n): y
Project aegir-up (7.x-2.0-alpha1) downloaded to C:\Users\Domas/.drush/aegir-up. [success]
Project aegir-up contains 0 modules: .
Lastly, I run vagrant-build to get a vagrant project going (I presume), this is where it fails:
C:\Users\Domas>drush vagrant-build --blueprint=aegir
The name of your project may be used in URLs, and so should only contain lower-case letter
s and numbers.
It may also contain hyphens (-) and dots (.), so long as they do not come at the beginning
or end of the name.
What would you like to call your project?: test
Would you like to generate entries in /etc/hosts for the VMs in your project? (y/n): y
You are about to:
* Create a new project called "test" at "C:\Users\Domas/vagrant/projects/test".
* Add entries for the FQDNs of the VMs to /etc/hosts. (You will be prompted for your sud
o password.)
* Generate Drush aliases for the project and VMs.
* Launch the project VMs immediately.
* Build the project using the "aegir" blueprint from the "aegirup" extension.
Do you want to proceed with initializing the project? (y/n): y
Copied the "aegir" blueprint directory to C:\Users\Domas/vagrant/projects/test. [ok]
'egrep' is not recognized as an internal or external command,
operable program or batch file.
symlink(): Cannot create symlink, error code(1314) vagrant.blueprints.inc:90 [warning]
Errors occurred when running "symlink()" in [error]
"vagrant_default_build_project_setup".
Drush command terminated abnormally due to an unrecoverable error. [error]
At first I thought, that simply Egrep was missing, I downloaded UnxUtils, added it to PATH and checked that Egrep runs from the command prompt, which it did. However, after redoing the aegir-up setup steps I still got the same errors.
I am not particularly familiar with any of these tools. I have VirtualBox, Vagrant, Drush and NFS server, Ruby, gem installed. Running on Win8. I have been searching for an answer the whole day. Could someone please shed some light on this?
Apparently, I needed to run these commands through an elevated shell (as in, right click on Command Prompt -> Run as Administrator). Cannot create symlink, error code(1314) was what I should have concentrated on. The commands ran. Other problems came up, namely – Windows path wasn't getting escaped properly; however, that is off question.
Edit: At the moment of posting this problem Aegir-up was not supported on Windows, simple enough. That's why I was having a multitude of problems trying to run it on them.

Running update-database from Team City

I have created a new application using Entity Framework 4.3 database migrations. The migrations work great from the package manager console using the "update-database" command.
Now I want to run the database migrations every time the application is built using Team City, it looks like I need to create a powershell script that will do this.
Can anyone point me to some instructions on how to get the package manager commands to run from the command line, or powershell? All I can find is instructions on how to do this via the package manager console, which I don't know how to run from a Team City build step.
migrate.exe is what I was looking for, it is found in "packages\EntityFramework.4.3.1\tools".
Add a new build step in Team City using:
Runner type: command line
Command executable: packages\EntityFramework.4.3.1\tools\migrate.exe
Command parameters: MyApplicationName /StartupDirectory:MyApplicationName\bin
Install Entity Framework nuget to the repo and use the accompanying migrate.exe under packages\EntityFramework.5.0.0\tools\ or equivalent.
Then run a batch script like this:
SET AssemblyName=MyMvc4App
SET StartUpDirectory=MyMvc4App\bin\
SET ConnectionString=Server=tcp:XXXX.database.windows.net,1433;Database=XXXX;User ID=XXXX;Password=XXXX;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;MultipleActiveResultSets=True
SET ConnectionStringProvider=System.Data.SqlClient
SET ConfigFilePath=%CD%\MyMvc4App\web.config
SET MigrateExe=packages\EntityFramework.5.0.0\tools\migrate.exe
%MigrateExe% %AssemblyName%.dll /startUpDirectory:%StartUpDirectory% /startUpConfigurationFile:"%ConfigFilePath%" /connectionProviderName:"%ConnectionStringProvider%" /connectionString:"%ConnectionString%" /verbose
pause
I answered a similar question and there I explain why I have yet to get it working without specifying a web/app.config file.

Resources