Skip to content

Commit

Permalink
Merge pull request #26 from ko4life-net/maintenance-docs
Browse files Browse the repository at this point in the history
Prefix migration scripts with 4 leading zeros and update docs
  • Loading branch information
stevewgr committed May 22, 2024
2 parents 1ad79c1 + 40f2882 commit 8e38ba5
Show file tree
Hide file tree
Showing 46 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.bak
tmp/
.venv/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Note that the development process is inspired from [different db development env

During development we only create migration scripts to alter the current state of the base. The base here refers to the generated scripts in data, procedure and schema.

Every migration script will be prefixed by index. For example, `1_insert_steve_user.sql` will contain an insert statement to `TB_USER` table.
Every migration script will be prefixed by max 4 leading zeros. For example, `0001_insert_steve_user.sql` will contain an insert statement to `TB_USER` table.

Apart from the benifit of having the database under version control, this also makes it easy to use any SQL version you want. I use both 2008 and 2022 and it works perfectly fine with both.

Expand Down
6 changes: 2 additions & 4 deletions src/migration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
Add here scripts that alters the existing database's schema, procedures, data and misc changes.

Couple of rules and notes when writing migration scripts:
- Try to avoid any unnecessary formatting (eventually we'll add a formatter and automation), as it bloats the final diff when exporting the db
- Always assume the database containing data, even if you just modify an empty table
- When altering Stored Procedures, always create a separate script for it
- When altering the schema, adding comments (`--` for tsql) are encouraged
- When merging Pull Requests, if the server or client also needs changes, first merge the db PRs before the client / server
- When submitting a PR, providing a `*.diff` file is encouraged (`.\import.ps1 -generate_diffs $true`)
- When submitting a PR, please generate a `*.diff` file and commit it (`.\import.ps1 -generate_diffs $true`)
- Every migration script should start with max 4 leading zeros (example `0001_insert_user.sql`)

## Creating a new release

Expand Down
Empty file removed src/migration/archive/.gitkeep
Empty file.
File renamed without changes.

0 comments on commit 8e38ba5

Please sign in to comment.