Migrations
What is it about?
The workflow of migrations allows you to manage changes to the data schema over time. Typically this involves making changes to the entities or the database context, creating a new migration, then applying the migration update to the database schema or revert if needed.
Examples
Creating migration files
frontier dotnet migrate [command] [options]
Command | Description |
---|---|
new | new migration |
up | apply all migrations |
down | revert to a previous migration |
remove | remove latest migration |
new
new will create a new migration. This does not apply the migration to the database.
Usage
frontier dotnet migrate new <migration-name>
Option | Description |
---|---|
--appContainer, -a [container] | Required This is the name of the container that is running the application (string ). |
--environment, -e [environment] | The target environment for the migrations to be applied. Default is Local (string ). |
--configuration, -c [configuration] | This can either be Debug or Release . The default is Debug (string ). |
--help | Show debug logs when creating the project. |
up
up will apply all the migrations to the database.
Usage
frontier dotnet migrate up
Option | Description |
---|---|
--appContainer, -a [container] | Required This is the name of the container that is running the application (string ). |
--environment, -e [environment] | The target environment for the migrations to be applied. Default is Local (string ). |
--configuration, -c [configuration] | This can either be Debug or Release . The default is Debug (string ). |
--help | Show debug logs when creating the project. |
down
down will revert already applied database migrations from the database
Usage
frontier dotnet migrate down [previous_migration_name]
Option | Description |
---|---|
--appContainer, -a [container] | Required This is the name of the container that is running the application (string ). |
--environment, -e [environment] | The target environment for the migrations to be applied. Default is Local (string ). |
--configuration, -c [configuration] | This can either be Debug or Release . The default is Debug (string ). |
--help | Show debug logs when creating the project. |
remove
remove will delete the most recently created migration. This will not revert already applied migration from the database unless specified.
Usage
frontier dotnet migrate remove
Option | Description |
---|---|
--appContainer, -a [container] | Required This is the name of the container that is running the application (string ). |
--prevMigration, -m [migrationName] | Revert all migrations applied to the database after the specified migration. Starting from the most recent migration (string ). |
--environment, -e [environment] | The target environment for the migrations to be applied. Default is Local (string ). |
--configuration, -c [configuration] | This can either be Debug or Release . The default is Debug (string ). |
--help | Show debug logs when creating the project. |
Using unsupported Dotnet EF Core Command
Learn more about all the available commands from Entity Framework Core
If you want to use commands that are currently not supported by frontier dotnet
then you are still in luck. All you need to do is:
1. Attach to the Docker container running the project
You are able to connect to the container using the docker exec
command. By default the container name will be the same name used when creating the project. You can also find the container name by using Docker desktop or the docker CLI.
docker exec -it <container-name | container-id> sh
2. Run your dotnet
commands
Execute the command you want from the root of your directory. This should be /app/src/
by default.
Example
dotnet ef migrations list