-
-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
…re-redemption
- Loading branch information
Showing
71 changed files
with
494 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,14 +47,6 @@ jobs: | |
with: | ||
install: true | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@main | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-x86-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-x86- | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
|
@@ -109,14 +101,6 @@ jobs: | |
with: | ||
install: true | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@main | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-arm-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-arm- | ||
- name: Build | ||
uses: docker/[email protected] | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Database Migration System | ||
|
||
This document provides an overview of the current database migration system for the project. The migration process has been streamlined to ensure that all migration scripts are automatically applied in order, making it easier to maintain database updates. | ||
|
||
## How It Works | ||
|
||
The migration system is designed to apply updates to the database schema or data whenever a new server version is started. Migration scripts are stored in the `migrations` directory, and the system will automatically apply any scripts that have not yet been executed. | ||
|
||
### Steps Involved | ||
|
||
1. **Retrieve Current Database Version**: | ||
- The system first retrieves the current version of the database using `getDatabaseVersion()`. | ||
- This version is used to determine which migration scripts need to be executed. | ||
|
||
2. **Migration Files Directory**: | ||
- All migration scripts are stored in the `migrations` directory. | ||
- Each migration script is named using a numerical pattern, such as `1.lua`, `2.lua`, etc. | ||
- The naming convention helps determine the order in which scripts should be applied. | ||
|
||
3. **Execute Migration Scripts**: | ||
- The migration system iterates through the migration directory and applies each migration script that has a version greater than the current database version. | ||
- Only scripts that have not been applied are executed. | ||
- The Lua state (`lua_State* L`) is initialized to run each script. | ||
|
||
4. **Update Database Version**: | ||
- After each migration script is successfully applied, the system updates the database version to reflect the applied change. | ||
- This ensures that the script is not re-applied on subsequent server startups. | ||
|
||
## Example Migration Script | ||
|
||
Below is an example of what a migration script might look like. Note that no return value is required, as all migration files are applied based on the current database version. | ||
|
||
```lua | ||
-- Migration script example (for documentation purposes only) | ||
-- This migration script should include all necessary SQL commands or operations to apply a specific update to the database. | ||
|
||
-- Example: Adding a new column to the "players" table | ||
local query = [[ | ||
ALTER TABLE players ADD COLUMN new_feature_flag TINYINT(1) NOT NULL DEFAULT 0; | ||
]] | ||
|
||
-- Execute the query | ||
db.execute(query) -- This function executes the given SQL query on the database. | ||
|
||
-- Note: Ensure that queries are validated to avoid errors during the migration process. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
function onUpdateDatabase() | ||
logger.info("Updating database to version 2 (hireling)") | ||
|
||
db.query([[ | ||
CREATE TABLE IF NOT EXISTS `player_hirelings` ( | ||
`id` INT NOT NULL PRIMARY KEY auto_increment, | ||
`player_id` INT NOT NULL, | ||
`name` varchar(255), | ||
`active` tinyint unsigned NOT NULL DEFAULT '0', | ||
`sex` tinyint unsigned NOT NULL DEFAULT '0', | ||
`posx` int(11) NOT NULL DEFAULT '0', | ||
`posy` int(11) NOT NULL DEFAULT '0', | ||
`posz` int(11) NOT NULL DEFAULT '0', | ||
`lookbody` int(11) NOT NULL DEFAULT '0', | ||
`lookfeet` int(11) NOT NULL DEFAULT '0', | ||
`lookhead` int(11) NOT NULL DEFAULT '0', | ||
`looklegs` int(11) NOT NULL DEFAULT '0', | ||
`looktype` int(11) NOT NULL DEFAULT '136', | ||
FOREIGN KEY(`player_id`) REFERENCES `players`(`id`) | ||
ON DELETE CASCADE | ||
) | ||
]]) | ||
|
||
return true | ||
logger.info("Updating database to version 1 (sample players)") | ||
-- Rook Sample | ||
db.query("UPDATE `players` SET `level` = 2, `vocation` = 0, `health` = 155, `healthmax` = 155, `experience` = 100, `soul` = 100, `lookbody` = 113, `lookfeet` = 115, `lookhead` = 95, `looklegs` = 39, `looktype` = 129, `mana` = 60, `manamax` = 60, `town_id` = 1, `cap` = 410 WHERE `id` = 1;") | ||
-- Sorcerer Sample | ||
db.query("UPDATE `players` SET `level` = 8, `vocation` = 1, `health` = 185, `healthmax` = 185, `experience` = 4200, `soul` = 100, `lookbody` = 113, `lookfeet` = 115, `lookhead` = 95, `looklegs` = 39, `looktype` = 129, `mana` = 90, `manamax` = 90, `town_id` = 8, `cap` = 470 WHERE `id` = 2;") | ||
-- Druid Sample | ||
db.query("UPDATE `players` SET `level` = 8, `vocation` = 2, `health` = 185, `healthmax` = 185, `experience` = 4200, `soul` = 100, `lookbody` = 113, `lookfeet` = 115, `lookhead` = 95, `looklegs` = 39, `looktype` = 129, `mana` = 90, `manamax` = 90, `town_id` = 8, `cap` = 470 WHERE `id` = 3;") | ||
-- Paladin Sample | ||
db.query("UPDATE `players` SET `level` = 8, `vocation` = 3, `health` = 185, `healthmax` = 185, `experience` = 4200, `soul` = 100, `lookbody` = 113, `lookfeet` = 115, `lookhead` = 95, `looklegs` = 39, `looktype` = 129, `mana` = 90, `manamax` = 90, `town_id` = 8, `cap` = 470 WHERE `id` = 4;") | ||
-- Knight Sample | ||
db.query("UPDATE `players` SET `level` = 8, `vocation` = 4, `health` = 185, `healthmax` = 185, `experience` = 4200, `soul` = 100, `lookbody` = 113, `lookfeet` = 115, `lookhead` = 95, `looklegs` = 39, `looktype` = 129, `mana` = 90, `manamax` = 90, `town_id` = 8, `cap` = 470 WHERE `id` = 5;") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
function onUpdateDatabase() | ||
logger.info("Updating database to version 11 (Guilds Balance)") | ||
db.query("ALTER TABLE `guilds` ADD `balance` bigint(20) UNSIGNED NOT NULL DEFAULT '0';") | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
function onUpdateDatabase() | ||
logger.info("Updating database to version 12 (Player get daily reward)") | ||
db.query("ALTER TABLE `players` ADD `isreward` tinyint(1) NOT NULL DEFAULT 1") | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
function onUpdateDatabase() | ||
logger.info("Updating database to version 14 (Fixed mana spent)") | ||
db.query("ALTER TABLE `players` CHANGE `manaspent` `manaspent` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0';") | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
function onUpdateDatabase() | ||
print("Updating database to version 17 (Tutorial support)") | ||
db.query("ALTER TABLE `players` ADD `istutorial` SMALLINT(1) NOT NULL DEFAULT '0'") | ||
return true -- true = There are others migrations file | false = this is the last migration file | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,4 @@ function onUpdateDatabase() | |
`monster_list` BLOB NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
]]) | ||
|
||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,6 +109,4 @@ function onUpdateDatabase() | |
ON DELETE CASCADE | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
]]) | ||
|
||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
function onUpdateDatabase() | ||
logger.info("Updating database to version 25 (random mount outfit window)") | ||
db.query("ALTER TABLE `players` ADD `randomize_mount` SMALLINT(1) NOT NULL DEFAULT '0'") | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
function onUpdateDatabase() | ||
logger.info("Updating database to version 26 (reward bag fix)") | ||
db.query("UPDATE player_rewards SET pid = 0 WHERE itemtype = 19202;") | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,4 @@ function onUpdateDatabase() | |
PRIMARY KEY (`id`), | ||
UNIQUE KEY `name` (`name`)) | ||
]]) | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
function onUpdateDatabase() | ||
logger.info("Updating database to version 29 (transfer coins)") | ||
db.query("ALTER TABLE `accounts` ADD `coins_transferable` int unsigned NOT NULL DEFAULT '0';") | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
function onUpdateDatabase() | ||
logger.info("Updating database to version 30 (looktypeEx)") | ||
db.query("ALTER TABLE `boosted_boss` ADD `looktypeEx` int unsigned NOT NULL DEFAULT '0';") | ||
return true | ||
end |
Oops, something went wrong.