Is there any possibility to migrate database changes to any specific version. As a example we have list of migration within out project and we want to migrate only version 2 changes into the database. I may have below migrations
Version 1 - Already in DB
Version 2 - Want to migrate to the DB
Version 3 - Will migrate later.
Is there any command like migrate:up --Version 2? I am using FluentMigrator.1.4.0.0
I manage to do this using below script.
Migrate.exe /connection "data source=source;initial catalog=db;User ID=sa;Password=123;" /db SQLserver2012 /timeout 600 /task migrate:up --version=2 /target ..\DatabaseMigration\bin\Debug\DatabaseMigration.dll
pause
Related
Is there a Linux equivalent of LightIngest.exe? The page of the utility does not mention that, search brings no luck either. In case it is not available, what is the preferred way to post ingestion items through CLI in Linux?
There is a .NET Core Kusto.Tools package - it is currently built for Core 2.1 and we will be working on updating it in the coming weeks.
https://www.nuget.org/packages/Microsoft.Azure.Kusto.Tools.NETCore/
Thanks to Vladik's answer I was able to download the package and use the included LightIngest.dll to execute an ingest through my Mac. Here are the steps:
Use nuget to download the Microsoft.Azure.Kusto.Tools.NETCore package installed:
nuget install Microsoft.Azure.Kusto.Tools.NETCore -Source nuget.org -OutputDirectory SPECIFY_OUTPUT_DIRECTORY
Navigate to the directory, and go to the tools subfolder. There you should find LightIngest.dll
Assuming you have dotnet installed (CLI) and SDK (v2.1) you should be able to execute an ingestion:
dotnet ./LightIngest.dll ...
Replace the ... with the Windows equivalent command that Azure Data Explorer Ingestion wizard suggested, and it should start ingesting!
I was running Symfony 4.4.8, and I wanted to update my project. So I ran:
composer update
It did automatically update the DoctrineMigrationsBundle (https://packagist.org/packages/doctrine/doctrine-migrations-bundle) from 2.1.2 to 3.0.1.
Composer failed at first because doctrine_migrations.yaml was not compatible with the DoctrineMigrationsBundle 3.0.1, so I ran:
composer recipes:install --force -v
composer install
But: it appears that the DoctrineMigrationsBundle v 3 has a totally different configuration and does not use the "migrations_versions" SQL table anymore, but a new "doctrine_migrations_versions"-table and a new migrations directory ('%kernel.project_dir%/migrations' instead of '%kernel.project_dir%/src/Migrations').
This means that every time you do:
php bin/console doctrine:migrations:diff
You will get in the migration:
$this->addSql('DROP TABLE migration_versions');
I read at https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html that you can set the table name in doctrine_migrations.yaml manually like this:
doctrine_migrations:
storage:
table_storage:
'table_name': 'doctrine_migrations'
But that is of no use, because the v 3 table has an extra column "execution_time" and in the "version" column a namespace is prepended (e.g. "DoctrineMigrations\Version20200702112735.php"). So both tables are incompatible.
I can't find any information anywhere on properly upgrading DoctrineMigrationsBundle from v2 to v3.
I must say I am surprised by this, I thought that "composer update" was to be safe. Appearently, one of the symfony bundles didn't add a version limit automatically where it should if an upgrade is not possible.
So what should I do? Should I just let composer downgrade the DoctrineMigrationsBundle again? Or is there some way to get an upgrade of DoctrineMigrationsBundle from v2 to v3 to work after all?
I think everything is explained here: https://github.com/doctrine/migrations/blob/master/UPGRADE.md
If you have already update the bundle config, just run that command:
bin/console doctrine:migrations:sync-metadata-storage
It should work.
I am currently working to get Flyway 3.0 version up to 4.2.0 and am having some trouble going from 3.0 -> 4.2.0. So far I've pulled in the 4.2.0 dependency and updated the renamed config fields.
When looking through the Flyway migration docs & issues it seemed that when a user runs flyway on version 4.2.0 that the checksums update automatically. I assumed that meant flyway migrate or any relevant commands would trigger this update, via the documentation:
Flyway 4.0 now ignores line endings when calculating checksums and all existing checksums in your metadata table will be automatically adjusted on first run to be compatible with this new algorithm.
However, the checksums did not update when running flyway migrate. As a work around, I found the helpful repair command which amends the migration checksum values from the old version to the new version and ran that:
flyway repair -user=user -password=password -url=jdbc:mysql://127.0.0.1:3306/db -table=db_migrations
Flyway 4.2.0 by Boxfuse
Database: jdbc:mysql://127.0.0.1:3306/db_migrations (MySQL 5.6)
Repair of failed migration in metadata table `db_migrations`.`schema_version` not necessary. No failed migration detected.
Successfully repaired metadata table `db_migrations`.`schema_version` (execution time 00:00.005s).
Manual cleanup of the remaining effects the failed migration may still be required.
Database: jdbc:mysql://127.0.0.1:3306/db_migrations (MySQL 5.6)
Repair of failed migration in metadata table `db_migrations`.`schema_version` not necessary. No failed migration detected.
Successfully repaired metadata table `db_migrations`.`schema_version` (execution time 00:00.004s).
Manual cleanup of the remaining effects the failed migration may still be required.
[1]- Done flyway repair -user=user -password=password -url=jdbc:mysql://127.0.0.1:3306/db -table=db_migrations
[2]+ Done flyway repair -user=user -password=password -url=jdbc:mysql://127.0.0.1:3306/db -table=db_migrations
The checksums updated but when I ran flyway info it shows that all the previous migrations are now marked future. Looking through the documentation future is defined:
These are migrations that were performed by a newer deployment of the application that are not yet available in this version. For example: we have migrations available on the classpath up to version 3.0. The schema history table indicates that a migration to version 4.0 (unknown to us) has already been applied.
However when checking the version I get the correct one:
flyway -v
Flyway 4.2.0 by Boxfuse
TLDR: Ran the repair command to update migration checksums and now flyway tells me the migrations have a checksum from a future version. Checked command line flyway and application flyway version and they are both at 4.2.0. Unsure how to debug / proceed. Any help would be appreciated.
Edit: Found one of the maintainers comments on another question defining future further
future -> executed, no longer found in configured locations, newer than the newest found script
So possibly the cmd line flyway can't locate the migration scripts it sees in the db?
There are many people that have asked this question before on SO. For the last 3 hours I have sequentially tried each solution, and I get the same No executable found matching command "dotnet-ef" each time. I'd like to understand how to run the command and have it actually execute.
But first a little background:
I am learning how to use ASP.Net Core 1.1 MVC and Entity Framework Core. It is a Microsoft tutorial that can be found here.
The completed tutorial can be downloaded from git, as instructed. Performing these steps I open the download project and follow the steps in the readme.md file in the project root folder. It states the following:
After downloading the project, create the database by entering dotnet
ef database update at a command-line prompt
Which I attempted. I used visual studio developer command prompt (as admin) and first change directory to the project root, where the appsettings.json and *.csproj file are located. I then typed in the following:
C:\Users\username\Downloads\Docs-master\aspnetcore\data\ef-mvc\intro\samples\cu-final>dotnet ef database update
No executable found matching command "dotnet-ef"
According to the tutorial, this should "work" as-is.
What is strange to me is that if I run the following command I get output, which indicates to me that dotnet.exe is working.
C:\Users\username\Downloads\Docs-master\aspnetcore\data\ef-mvc\intro\samples\cu-final>dotnet
--version
1.0.4
I am using Windows 10 and Visual Studio 2017 CE Version 15.2. I have both the ASP.NET and web development and .Net Core cross-platform development workloads installed.
I am also using .Net Framework Version 4.6.01586.
Make sure you restore first so that the ef tools become available:
Execute dotnet restore and wait for it to restore successfully, then execute dotnet ef database update.
Microsoft.EntityFrameworkCore.Tools.DotNet needs to be added to your project. Right click the project and select Edit *.csproj. Then, add the following:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-preview2-final" />
</ItemGroup>
Note: the version is the latest at the time of this post and will likely change in the future.
These tools can only be added by editing the .proj directly at this time.
The easiest way it run commands is to right click the project and Open Folder in File Explorer. Then, type cmd in the address bar of the File Explorer to open a command prompt in that folder. Now use the following command to create the initial migration:
dotnet ef migrations add InitialCreate
I want to use flyway for an existing application.
There should be two different cases:
1) Application installation: DDL and initilization of the Database
2) Application update: migrate database
The problem is if i install Version 6.0 i have e.g.:
V1_0_1__CreateShema (for 6.0.0)
V1_0_2__InitData (for 6.0.0)
....
V4_0_0__Update_DDL_and_DML
V5_0_0__Update_DDL_and_DML
V6_0_0__Update_DDL_and_DML
If i set init version to V1.0.0 it will execute all updates until V6_0_0 but it should skip all updates after initialization of the Database.
To install an old shema so i can use all udpate scripts even for a fresh install would be very hard (no db version history so i have to do reverse engineering)
I could use a workaround:
1) Check if version table exist
2) If not - migrate to version 1.0.2
3) drop the version table
4) init again with version 6.0.0
There should be a better way isnt it?
I've highlighted the problem:
V1_0_1__CreateShema (for 6.0.0)
V1_0_2__InitData (for 6.0.0)
To get to 6.0 you should run all scripts up to V6_0_0__Update_DDL_and_DML
V1 should be for V1 and never change afterwards.