Add server/src/schema.sql
This commit is contained in:
34
server/src/schema.sql
Normal file
34
server/src/schema.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
username TEXT UNIQUE NOT NULL,
|
||||
passhash TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS characters (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
|
||||
name TEXT NOT NULL,
|
||||
x INTEGER NOT NULL DEFAULT 100,
|
||||
y INTEGER NOT NULL DEFAULT 100,
|
||||
level INTEGER NOT NULL DEFAULT 1,
|
||||
xp BIGINT NOT NULL DEFAULT 0,
|
||||
last_login TIMESTAMPTZ
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS items (
|
||||
id SERIAL PRIMARY KEY,
|
||||
key TEXT UNIQUE NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
stack_max INTEGER NOT NULL DEFAULT 999
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS inventory (
|
||||
id SERIAL PRIMARY KEY,
|
||||
character_id INTEGER REFERENCES characters(id) ON DELETE CASCADE,
|
||||
item_key TEXT NOT NULL,
|
||||
qty INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS inventory_unique_item
|
||||
ON inventory (character_id, item_key);
|
||||
Reference in New Issue
Block a user