dbup | Tracking database schema versions | Database library
kandi X-RAY | dbup Summary
kandi X-RAY | dbup Summary
Copyright (c) 2008 by Konstantin Merenkov Project’s homepage: See LICENSE file in the same directory as this README. In short - MIT.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Parse command line arguments .
- Set the current version of the database .
- Connect to the database server .
- Create an instance of this class .
- Loads a Stage .
- Execute a SQL file
- Return the email address of the author .
- Roll back the current session .
- Initialize the connection parameters .
- Add a subscriber .
dbup Key Features
dbup Examples and Code Snippets
Community Discussions
Trending Discussions on dbup
QUESTION
Why is not exists
for the insert into #productType
table resulting in duplicates? Seems like it should work and I see a ton of SO answers using the same solution but it simply doesn't work. The expected result is to have only a single row inserted into the #productType
table.
All of my code is running under a transaction using DbUp, so I can't use the merge
statement either. Any ideas on how to modify this?
ANSWER
Answered 2021-Aug-13 at 06:09You can't do this, as the "not exists" is checked against the producttype state that it was at before this statement ran. so you would have to loop and insert 1 at a time. Best approach would just to use the distinct keyword.
You query will only ever work on tables which contain data.
Change your query to this:
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)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dbup
You can use dbup like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
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