how Handling EF Core migrations in a team - asp.net

I got into an argument with a co-worker regarding EF Core migrations and how we should handle them in a team environment. The current process we use (which I designed) is to use a branch with our names and self databases so every changes we make , we add-migration in our databases and branches and then merge our branches to develop branch. to prevent conflicts with migrations we add migration folder in gitignore in our branches. but the problem is we dont have migration history in git. but i have problem with this becuase we should have all changes in git.
Are there any best practices regarding this? we want to have migration histories in git branches and prevent EF Core migrations in a team?
how Handle EF Core migrations conflict in a team with different branches?

Everyone should be working on the same set of migrations checked into git. They can add (and remove) new ones locally while developing features, but as you said, they need to be careful when pushing and pulling changes that might conflict.
See Migrations in Team Environments for pointers.

Related

How can I set defaults for startup project and migration project in .NET Entity Framework Migrations?

I have my DbContext class living in a separate project from my entry point (startup) project. This means when I run dotnet ef CLI commands I need to specify the --startup-project and/or --project options every time. This works but is inconvenient.
I'm wondering if there is a way to save the values for these options somewhere so that I don't have to specify them every time I need to run a dotnet ef command. I'm thinking it would probably be somewhere in the startup project's .csproj file, or a separate .json defaults file that dotnet reads that points to the project where the migrations live.
I've searched around the CLI docs but don't see any capabilities like this mentioned. I'm hoping an option like this exists but is not documented (or that I missed it), or that somebody has a workaround to avoid having to specify these values every time.

Flyway change versioning in production system

I have started a project using a simple incremental versioning scheme like V1__, V2__, V3__.
I'm not happy with it. It causes problems when working on multiple branches: pull-requests need to be updated with the latest number when a different branch which has added migrations is merged before.
We have already deployed migrations to production.
Is it possible to change the versioning scheme after the fact?
I feel that simply renaming it will cause Flyway to throw an Exception. We cannot clear the production database.
Does anybody have experience with this? Any tips are appreciated.

Alter an already published build

Is there a way to alter a build using the CLI after having published it?
UseCase: A deployer (be it automated or manual) wants to add additional files (e.g. Testresult-logs) to an already published build (because they need very long to be created but the artifacts of the fresh build should be published asap).
When I redo a jfrog rt bp over and over again I get "new" builds with the same description (same buildnumer etc.) instead of overwriting/extending existing build.
Appreciating any hint :-)
The main idea of the buildinfo in Artifactory is that they are immutable, which means they cannot be modified post publish. This is to make sure the integrity of them.
In your case, a possible way to achieve this may be:
When publishing the artifacts themselves, you might want to not publish the buildinfo.
You can collect buildinfo through your build cycle, and publish everything as a single buildinfo object after all the tests.

How to handle doctrine migrations in bundles

I'm developing an application, using Symfony 2.3, which will have to be installed for different customers. We will offer different features so the idea is to have the features/bundles separate from the main app and load the into the project using composer. As we are using Doctrine Migrations to maintain DB changes across versions I'm unsure on how to go about using them from a bundle. We're using Capifony to deploy the app to the live server.
So my question is... how can I automatize the execution of migrations from composer loaded bundles?
I ended up creating a command that will copy all migration files from predefined directories in bundles to the default location and then executing doctrine:migrations:migrate from within the command.
For a complex deployment, I used phing. He easily integrate with the Symfony console. But in the end I use of a simple code on the Synfony console.
Composer can easily call Symfony app commands as "post-install-cmd"
I don't think "composer loaded bundles" is the issue here. For instance, you could have several bundles in src/ (part of the app or submoduled) and have the exact same problem. The issue is having multiple entity managers and databases for your different bundles. Where they actually reside is trivial.
Anyway, I'm having the exact same problem. After some searching, I discovered there is actually an open pull request to fix this: https://github.com/doctrine/DoctrineMigrationsBundle/pull/46
I'm hoping it gets fixed soon!

Release Symfony2 project to the web

I have almost finished the development of a project developed with Symfony2, and wish to put the project online.
However, I suppose there are a lot of things that need to be done so that everything works ok. I suppose, the dev mode needs to be disabled etc....What needs to be done and how?
What are the most important things to do on a Symfony2 project that will be available to everyone on the web?
I suggest you to use Capifony for deployment. It does a lot of stuff out of the box and you can make it run any custom commands you need. See its documentation for details.
Regarding the dev mode, unless you've removed the IP checks from app_dev.php, you don't have to worry about deploying it. Of course, if you wish, you can tell Capifony to delete it on deployment.
The best way to handle deployment is to create "build" script, which will:
Remove all folders and files with tests from your bundles and vendors.
Remove app_dev.php file
Make sure that app/cache and app/logs are fully writable/readable.
Packs your project into archive (rpm f.e.)
Then, before deployment, you should create tag in your project - so it will mean, that certain version of your application is released (I recommend to follow this git branching model).
Create tag.
Run your build script
Upload archive to host
Unpack
Enjoy your project
Im currently researching the same thing.
The first thing you have to consider is "how professional" you want to deploy. There are a lot of tools you can use:
Continous Integration Server ( e.g. Hudson, Jenkins)
Build Tools (e.g. Phing, Capistrano --> Capifony, Shell scripts)
Versioning Tools (e.g. Git, SVN)
I think the simplest setup is using only a Build tool and i guess you are already using some kind of versioning.
Depending on which tool you use, the setup is different, but I think there are some things you should consider with your application (maybe not all are applicable to your application)
Creating a Tag in your Versioning
Copying the new Code in an folder on production
--> if you are in a new folder you dont need to clear the cache and logs, since these shouldnt be in your versioning the first time.
loading composer (if youre using it)
installing vendors
updating database schema
install assets from your bundles
move symlink from current version to the folder of the new site
These are the things I currently need for my application for production deployment, if you deploy to an test environment you should load fixtures and run your testscripts as well.
One other option that is very well described here is to deploy the Symfony2 application with Apache Ant. Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other.

Resources