mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-22 04:32:49 +00:00
feat(db): guilds, guild_members, guild_invites and guild_events
Four tables (MySQL migration 97, SQLite 80) and the IGuilds interface with MySQL, SQLite and TestSQL implementations, for the guild system (docs/Guilds.md). A guild has a name (unique without regard to case), a name status like pet_names (1 waiting for moderation, 2 approved), its founder and when it was made. A character is in at most one guild (guild_members, with its rank: 1 leader, 2 officer, 3 veteran, 4 recruit, the client's names, and when it joined) and has at most one pending invite (guild_invites). guild_events is each guild's history and outlives the guild. Deleting a character removes its membership and the invites to and from it. Nothing uses the tables yet. Check: both migrations run on a fresh and an existing database; DatabaseParityTests Guilds passes against MariaDB (DLU_TEST_MYSQL_HOST) and SQLite gives the same results. Nothing to check in game. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
40
migrations/dlu/mysql/97_guilds.sql
Normal file
40
migrations/dlu/mysql/97_guilds.sql
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Guilds (docs/Guilds.md), owned by the chat server. The leader is the member with guild_rank 1 (1 leader, 2 officer,
|
||||
3 veteran, 4 recruit). name_status: 1 = the name waits for moderation, 2 = approved (as pet_names.approved).
|
||||
A character is in at most one guild (guild_members) and has at most one pending invite (guild_invites).
|
||||
guild_events is each guild's history; it is kept when a guild is disbanded. */
|
||||
CREATE TABLE IF NOT EXISTS guilds (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(64) NOT NULL,
|
||||
name_status INT NOT NULL DEFAULT 1,
|
||||
founder_id BIGINT NOT NULL DEFAULT 0,
|
||||
created_at BIGINT NOT NULL,
|
||||
UNIQUE INDEX guilds_name (name)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS guild_members (
|
||||
character_id BIGINT NOT NULL PRIMARY KEY,
|
||||
guild_id BIGINT NOT NULL,
|
||||
guild_rank TINYINT UNSIGNED NOT NULL,
|
||||
joined_at BIGINT NOT NULL,
|
||||
INDEX guild_members_guild (guild_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS guild_invites (
|
||||
character_id BIGINT NOT NULL PRIMARY KEY,
|
||||
guild_id BIGINT NOT NULL,
|
||||
inviter_id BIGINT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
INDEX guild_invites_guild (guild_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS guild_events (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
guild_id BIGINT NOT NULL,
|
||||
time BIGINT NOT NULL,
|
||||
kind VARCHAR(24) NOT NULL,
|
||||
character_id BIGINT NOT NULL DEFAULT 0,
|
||||
character_name VARCHAR(35) NOT NULL DEFAULT '',
|
||||
actor VARCHAR(64) NOT NULL DEFAULT '',
|
||||
detail VARCHAR(255) NOT NULL DEFAULT '',
|
||||
INDEX guild_events_guild (guild_id, id)
|
||||
);
|
||||
36
migrations/dlu/sqlite/80_guilds.sql
Normal file
36
migrations/dlu/sqlite/80_guilds.sql
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Guilds, owned by the chat server. See the MySQL migration. */
|
||||
CREATE TABLE IF NOT EXISTS guilds (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL COLLATE NOCASE UNIQUE,
|
||||
name_status INTEGER NOT NULL DEFAULT 1,
|
||||
founder_id BIGINT NOT NULL DEFAULT 0,
|
||||
created_at BIGINT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS guild_members (
|
||||
character_id BIGINT NOT NULL PRIMARY KEY,
|
||||
guild_id BIGINT NOT NULL,
|
||||
guild_rank INTEGER NOT NULL,
|
||||
joined_at BIGINT NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS guild_members_guild ON guild_members (guild_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS guild_invites (
|
||||
character_id BIGINT NOT NULL PRIMARY KEY,
|
||||
guild_id BIGINT NOT NULL,
|
||||
inviter_id BIGINT NOT NULL,
|
||||
created_at BIGINT NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS guild_invites_guild ON guild_invites (guild_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS guild_events (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
guild_id BIGINT NOT NULL,
|
||||
time BIGINT NOT NULL,
|
||||
kind TEXT NOT NULL,
|
||||
character_id BIGINT NOT NULL DEFAULT 0,
|
||||
character_name TEXT NOT NULL DEFAULT '',
|
||||
actor TEXT NOT NULL DEFAULT '',
|
||||
detail TEXT NOT NULL DEFAULT ''
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS guild_events_guild ON guild_events (guild_id, id);
|
||||
Reference in New Issue
Block a user