dbup | php simple migration tool | Data Migration library
kandi X-RAY | dbup Summary
kandi X-RAY | dbup Summary
Dbup is a simple migration tool for PHP. Applied migration sql files are copied to .dbup/applied directory. If a same file exists both sql and .dbup/applied directory, up command ignores this sql file.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Execute the command
- Get up candidates .
- Get sql status
- Create a migration .
- Run up the migrations .
- Compile databaseup .
- Configure the database .
- Get stub .
- Get PDO connection .
dbup Key Features
dbup Examples and Code Snippets
Community Discussions
Trending Discussions on dbup
QUESTION
I created a new .Net 5 project and want to use EF Core. I autogenerated multiple migration.cs files using
dotnet ef migrations add MyMigration
and want to apply them (for development and production). I know about the MigrateAsync
method so I read about how to call this method on startup
https://andrewlock.net/running-async-tasks-on-app-startup-in-asp-net-core-part-1/
but everywhere I read that this method should not be used for production since those migrations won't be executed in a single transaction (no rollback on errors).
Unfortunately there are not many resources on how to do it regardless of the environment, I found this article
One option could be a console app calling the migrations
but I wasn't able to understand the difference for this approach because it's not solving the transactional problem?
What are best practises to apply migrations during development/production?
After autogenerating migrations I'm a big fan of simplicity, does
dotnet ef database update
the job and I don't need to work with additional tools?Create a console app, generate .sql files from the migrations, install DbUp and use it for the migration part?
ANSWER
Answered 2021-Jun-01 at 23:42What works best heavily depends on how deployment pipeline works - how many environments are there before production, release cycle, what parts of deployment are automated. There are no universal "best practices" - each way of handling migrations has its own set of tradeoff to be concious about. Pick upgrade procedure according to what your needs and expectations are.
When setting up EF Core migrations for a mid-sized project (around 70 tables), I tried out few potential approaches. My observations from the process and what worked out in the end:
- You want to get a migration SQL somewhere between changing your models and deploying to production, if only to look at it in case there are any breaking changes that may cause issues on rollback. We decided on having migrations directly in project with dbcontext, and have a migration script (using
dotnet ef migrations script --idempotent
) be generated for every build that can potentially be deployed to any environment - in our case, a CI step for each push to trunk or release branch. - Putting migration SQL in version control and treating SQL as a source of truth in regards to database structure gives an ability to manually modify scripts when you want to keep some columns for backup or backwards compatibility purposes. Another option would be to consider your data model as a reference for database schema and treat migration SQL as intermediate step that is not preserved, which makes it easier to automate whole process, but requires you to handle special cases directly in your datamodel.
- Using
--idempotent
flag when generating migration script gives you a script you can reapply to a database schema regardless of what schema version it was at, having it execute only steps that were not yet executed. This means you can reapply same migration script to already migrated database without breaking schema. If you have different versions of your application running in parallel in separate environments (development, staging and production environment), it can save issues with tracking manually what migration scripts version you need to apply and in what order. - When you have migration SQL, you can use native for your database tools in order to apply them to target environment - such as
sqlcmd
for SQL Server,psql
for postgres. This also has a benefit of having separate user with higher privileges (schema modification) handle migrations, while your application works on limited privileges, that often can't touch the schema. - Applying database migrations is part of application deployment, not application startup - if you have deployment automation of some sorts, it's probably the best place to put executing migrations against target database, again - database native client is a good alternative to
DbUp
, pick whichever you prefer. Separating migrations from application startup also gives you ability to run an application against mismatched, but still compatible database schema - which comes handy when e.g. you're doing rollout deployments. - Most problems with schema upgrades come from breaking schema compatibility between versions - avoiding that requires being concious about backwards/forward compatibility when working on data model and splitting breaking changes into separate versions that keep at least single step of backwards/forwards compatibility - whether you need it depends on your project, it's something you should decide on. We run full integration test suite for previous version against current database schema and for current version against previous database schema to make sure no breaking changes are introduced between two subsequent versions - any deployment that moves multiple versions will roll out migrations one by one, with assumption that migration script or application startup can include data transformation from old to new model.
To sum up: generating migration SQL and using either native tools or DbUp on version deploy gives you a degree of manual control over migration process, and ease of use can be achieved by automating your deployment process. For development purposes, you may as well add automatic migrations on application startup, preferably applied only if environment is set to Development
- as long as every person on a team has its own development database (local SQL, personal on a shared server, filedb if you use SQL) there are no conflicts to worry about.
QUESTION
Recently I had Azure Pipeline builds start failing, without any changes to my build scripts/yaml. The errors are as follows but they're still pretty light on the details.
...ANSWER
Answered 2021-Jun-07 at 01:59The issue was in fact due to the FscToolPath
evaluating to an empty string.
Existing error message accurately conveys the issue; it’s not F#-specific. Something in the .props/.targets files evaluates to dotnet $(PathToFsc) some/file.rsp and the variable $(PathToFsc) (or whatever is in your build scripts) is evaluating to an empty string. The final command that’s executed is then dotnet some/file.rsp and the normal dotnet behavior is to look for dotnet- as an executable.
The second factor was that the location of FSC did change due to an update of Visual Studio on the VM Image.
Not an answer, but I wonder if it's related to this: stackoverflow.com/questions/67800998/… - it seems things may have moved between VS 16.9 and 16.10.
Finally why it impacted me was because I was setting the FscCompilerPath manually due to a TypeProvider that did not support the dotnet core pipeline due to a dependency on System.Data.SqlClient
.
QUESTION
What's the best way to migrate an Azure search schema in a release pipeline?
In the SQL world, I'd use something like DbUp. Is there anything similar for Azure search? Or is there a different approach when the schema needs to change?
...ANSWER
Answered 2021-Feb-08 at 14:46It depends on whether you are pushing content via the SDK or if you are pulling content from a supported content source using one of the pre-built indexers. Using the SDK you can add new properties to your model as explained in this post: Update Azure search document schema
Note: Changes in your data model may require either an update or a rebuild of the index. For example, adding new properties only requires and update. But, if you change a setting like searchable, filterable or sortable you will need a rebuild. For details, see How to rebuild an index in Azure Cognitive Search
COMPATIBILITY PROBING VIA PUSH
My preferred solution is to use push indexing for everything. To test if the data model in the index is compatible, I create a sample item and submit to the index. If the model used in the index is incompatible, and error is thrown by the Azure Search SDK. I then delete the index and create it from scratch using my new model.
Here is a simplified method to test if any item is compatible with a named index:
QUESTION
I installed the latest DbUp version 4.4.0 from nuget and followed the steps described in the docs
https://dbup.readthedocs.io/en/latest/
I'm using a MySQL database and created a new .NET Core console project.
There is no database present yet. I deleted it
I installed the dbup and dbup-mysql package
I copied the sample code from the docs and modified it a little bit
...
ANSWER
Answered 2020-Aug-05 at 11:33The table schemaversions was added correctly but the problem is that you drop the database in your initial script. DbUp does not add it again.
QUESTION
In my YAML pipeline I have a deployment job:
...ANSWER
Answered 2020-Apr-24 at 01:46I can't test UpdateDatabaseWithDbUp@2
but I have sth what explain how you can achieve your goal. First define templeate.yaml
QUESTION
I'm using .net core 2.1 project with DBUP library, but when I try to run the DBUP inside octopus deploy the migration tool is returning an error System.Data.SqlClient is not supported on this platform.
I followed all these steps from an Octopus Documentations https://octopus.com/blog/dbup-database-deployments...
Already did this steps to fix the problem but without success:
- net core SDK 2.1, 2.2 installations on the target server
- Restart the server
- New release with System.Data.SqlClient nuget package associated with the DBUP Project
Not sure what I can do more to fix this issue
...ANSWER
Answered 2020-Mar-19 at 17:51Found the problem, DBUP project needs to be published isolated from other projects.
My bad was, trying to run/use dbupproject.dll file as a reference from other projects.
QUESTION
I am trying to use DbUp to set up migration scripts for my Database. Problem is whenever I use:
...ANSWER
Answered 2020-Feb-22 at 23:16Problem happens with 4.3.0 release. Downgrade to 4.0.0 and it won't happen anymore (as a temporary fix till a stable one)
QUESTION
I am trying to create integration tests for my microservices similar to Spotify's approach.
I am still working on how to spin up and seed the database. Currently I have a .NET Core 2.0 project with FluentDocker v2.2.15 and DbUp 4.1.0.
I use FluentDocker to call DockerCompose and start my services, including the SQL Server container
...ANSWER
Answered 2018-Oct-03 at 18:49You can use WaitForPort
, WaitForProcess
, WaitForHttp
, or custom lambda Wait
functions on compose in FluentDocker v2.6.2. For example:
Given the docker-compose file:
QUESTION
Running an Azure (CentOS 7 client) build pipeline with a command
# Run DB migrations
dotnet run --project $(Build.Repository.LocalPath)/DBMigrations
this job is shown as completed successfully, although there was an exception
System.Data.SqlClient.SqlException
and I used
failOnStderr: true
in my pipeline configuration.
Migrations code:
...ANSWER
Answered 2019-Jul-12 at 12:45The problem was in
QUESTION
Im trying to use the example code from dbup converted to postgres.
Below is the code.
...ANSWER
Answered 2019-May-26 at 19:03I know this is an old question but today I ran into the same problem and since there is no answer yet I'm answering for future reference:
I found that DbUp is trying to create a "schemaversions" but there is no default schema set. This results in the error:
Getting 'relation "schemaversions" does not exist error'
Setting the default schema fixed the problem for me:
builder.JournalToPostgresqlTable("SCHEMA_NAME", "schemaversions")
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dbup
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page