29 lines
794 B
SQL
29 lines
794 B
SQL
DROP TABLE IF EXISTS users;
|
|
CREATE TABLE users (
|
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
`username` TEXT NOT NULL UNIQUE,
|
|
`email` TEXT NOT NULL UNIQUE,
|
|
`password` TEXT NOT NULL,
|
|
`auth` INT NOT NULL DEFAULT 0,
|
|
`char_id` INTEGER NOT NULL DEFAULT 0,
|
|
`char_slots` INTEGER NOT NULL DEFAULT 2,
|
|
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
`last_login` DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
DROP TABLE IF EXISTS sessions;
|
|
CREATE TABLE sessions (
|
|
`user_id` INTEGER NOT NULL,
|
|
`token` TEXT NOT NULL UNIQUE,
|
|
`expires` INTEGER NOT NULL
|
|
);
|
|
CREATE INDEX idx_sessions_token ON sessions (`token`);
|
|
|
|
DROP TABLE IF EXISTS tokens;
|
|
CREATE TABLE tokens (
|
|
`user_id` INTEGER NOT NULL,
|
|
`token` TEXT NOT NULL UNIQUE,
|
|
`created` INTEGER NOT NULL
|
|
);
|
|
CREATE INDEX idx_tokens_user_id ON tokens (`user_id`);
|