Skip to content

Commit

Permalink
Update database-migrations.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dhedey authored Jan 10, 2025
1 parent be23610 commit 75d8c07
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions docs/database-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,17 @@ Providing the schema **ONLY** at the user level i.e `ALTER user someuser in data

### Idempotent SQL script

This is a Raw SQL script that has to be executed on the database.

It takes care of applying each migration only once and applying only missing migrations.

It can be found in the [migrations directory](../src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql)
This is a Raw SQL script that has to be executed on the database. It takes care of applying each migration only once and applying only missing migrations. It can be found as [IdempotentApplyMigrations.sql](../src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql) in the migrations directory.

Before running the script, may need to ensure that the user running the script has SUPERUSER privileges, for example with:

```sql
ALTER USER db_dev_superuser WITH SUPERUSER;
```

For more information check:
https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/applying?tabs=dotnet-core-cli#idempotent-sql-scripts
For more information, see the [Microsoft documentation](https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/applying?tabs=dotnet-core-cli#idempotent-sql-scripts) on the idempotent SQL scripts.

Because of a bug in CLI responsible for generating these SQL scripts https://github.com/dotnet/efcore/issues/24512, it is possible that it will generate invalid SQL scripts (missing semicolon at the end of each command). We are trying to make sure it does not happen but since we are internally using docker images to migrate the database there is a chance that it might slip through. To fix that, simply add a semicolon at the end of the invalid command.
Because of [a bug in CLI responsible for generating these SQL scripts](https://github.com/dotnet/efcore/issues/24512), it is possible that it will generate invalid SQL scripts (missing semicolon at the end of each command). We are trying to make sure it does not happen but since we are internally using docker images to migrate the database there is a chance that it might slip through. To fix that, simply add a semicolon at the end of the invalid command.

## Schema upgrade scenarios
There are two scenarios that might happen between gateway versions.
Expand Down

0 comments on commit 75d8c07

Please sign in to comment.