diff options
| author | Walter Pagani <paganiwalter@gmail.com> | 2022-07-17 12:56:18 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-17 17:56:18 +0200 |
| commit | 5328700856155e61130d744cb126ce14c3c3d231 (patch) | |
| tree | 46c2132ce92f91fb7ed306678b2127e185586a87 /docs/sql-versioning.md | |
| parent | 82b8bf1122134d2a8c4e1821695867fe5d938b34 (diff) | |
| download | wiki-5328700856155e61130d744cb126ce14c3c3d231.tar.gz wiki-5328700856155e61130d744cb126ce14c3c3d231.tar.bz2 wiki-5328700856155e61130d744cb126ce14c3c3d231.zip | |
Add/Update (Translation/ES) sql-versioning (#783)
Diffstat (limited to 'docs/sql-versioning.md')
| -rw-r--r-- | docs/sql-versioning.md | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/docs/sql-versioning.md b/docs/sql-versioning.md index 18d60c7..beaa4ad 100644 --- a/docs/sql-versioning.md +++ b/docs/sql-versioning.md @@ -7,7 +7,6 @@ redirect_from: "/SQL-Versioning" We've two kind of versions: - Chronological versioning, For accepted sql files - - Versioning by id, mostly used for pending sql ## Chronological Versioning @@ -18,10 +17,9 @@ In order to achieve this, we use a specific **convention for file names** and we ### File names -The file name should not be renamed and should be kept as the name `creat_sql.sh` has created for the file. +The file name should not be renamed and should be kept as the name `create_sql.sh` has created for the file. -The file name will look like this: -`rev_XXXXXXXXXXXXXXXXXXX` +The file name will look like this: `rev_XXXXXXXXXXXXXXXXXXX` ### SQL Header @@ -29,20 +27,25 @@ The SQL Header is a special query that **must** be added at the top of the conte The format is the following: -ALTER TABLE version_db_**database** CHANGE COLUMN **previous_file_name** **this_file_name** bit; +```sql +ALTER TABLE version_db_[database] CHANGE COLUMN [previous_file_name] [this_file_name] bit; +``` Replacing: -- *database* with **world**, **character** or **auth** -- *previous-file-name* with the name of the latest file ( without extension ) -- *this-file-name** with the name of the new file itself ( without extension ) + +- **[database]** with **world**, **character** or **auth** +- **[previous_file_name]** with the name of the latest file (without extension) +- **[this_file_name]** with the name of the new file itself (without extension) The following is an example of the SQL Header query ( for auth database ): -`ALTER TABLE version_db_auth CHANGE COLUMN 2016_07_09_01 2016_07_10_00 bit;` +```sql +ALTER TABLE `version_db_auth` CHANGE COLUMN 2016_07_09_01 2016_07_10_00 bit; +``` ## Versioning by id -Pending sql files cannot use the protection system described above because we are not able to know previously the date when they will be accepted. +Pending sql files cannot use the protection system described above because we are not able to know previously the date when they will be accepted. So we're using an optional versioning ( but recommended for devs and expecially for pull requests ). @@ -50,17 +53,25 @@ We've introduced a field inside version_db_* tables that is a primary key strin For example you can create a version "X" that is related to a version "Y" that is not necessary the previous one. -currently we're using this bash command to avoid, as much as possibile, collisions between revisions: date +%s%N +Currently we're using this bash command to avoid, as much as possibile, collisions between revisions: + +```bash +date +%s%N +``` -if a collision happens ( extremely hard ), it can be easily solved manually however. +If a collision happens ( extremely hard ), it can be easily solved manually however. -the final query will be: +The final query will be: -`INSERT INTO version_db_auth(sql_rev,required_rev) VALUES ('1472557015805232200','1472557004102672900');` +```sql +INSERT INTO `version_db_auth` (`sql_rev`, `required_rev`) VALUES ('1472557015805232200','1472557004102672900'); +``` -or in case of not required_rev: +Or in case of not required_rev: -`INSERT INTO version_db_auth(sql_rev) VALUES ('1472557015805232200');` +```sql +INSERT INTO `version_db_auth` (`sql_rev`) VALUES ('1472557015805232200'); +``` Adding it in first line of your sql, it generates an error in case of double import; Such as for chronological versioning. @@ -70,6 +81,6 @@ There's a bash script under pending_* folders that will create an sql with this As said before, we've a special workflow for PR to allow db data consistency for devs -it requires some stuffs to be done on your PR's sql to be compatible with our import system and allow you to avoid double importing of same queries. +It requires some stuffs to be done on your PR's sql to be compatible with our import system and allow you to avoid double importing of same queries. -The how to is described under [How to create a PR](How-to-create-a-PR) article
\ No newline at end of file +The how to is described under [How to create a PR](How-to-create-a-PR) article |
