All checks were successful
Deploy triz-docs to 150 / build-and-deploy (push) Successful in 1h8m49s
1.1 KiB
1.1 KiB
| sidebar_position | title |
|---|---|
| 3 | Creating Migrations |
Creating Migrations
Every new database modification must be added as a completely new migration file.
Naming Convention
Flyway requires an exact naming format to recognize and order migrations correctly:
V<version>__<description>.sql
Examples
V1__initial_schema.sqlV2__task301_add_tables_t1_t2.sqlV3__add_client_phone.sqlV4__fix_invoice_indexes.sql
Warning
Important Rules:
- You must use exactly TWO underscores (
__) after the version number.- Never modify old executed migrations.
- Never rename old migrations after they have been executed on any environment.
- Always create a new migration file for new changes.
Example Workflow
If you need to add new tables for a specific task (e.g., Task 301), create a file named V2__task301_add_tables_t1_t2.sql with the necessary content:
CREATE TABLE table1 (
id BIGSERIAL PRIMARY KEY
);
CREATE TABLE table2 (
id BIGSERIAL PRIMARY KEY
);
Commit this file alongside your application code changes and push it to the repository.