diesel -> sqlx, patch cve (again lul)
This commit is contained in:
parent
a5cac129dd
commit
c3bb6d0d67
39 changed files with 1581 additions and 1207 deletions
|
@ -1,6 +0,0 @@
|
|||
-- This file was automatically created by Diesel to setup helper functions
|
||||
-- and other internal bookkeeping. This file is safe to edit, any future
|
||||
-- changes will be added to existing projects as new migrations.
|
||||
|
||||
DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass);
|
||||
DROP FUNCTION IF EXISTS diesel_set_updated_at();
|
|
@ -1,36 +0,0 @@
|
|||
-- This file was automatically created by Diesel to setup helper functions
|
||||
-- and other internal bookkeeping. This file is safe to edit, any future
|
||||
-- changes will be added to existing projects as new migrations.
|
||||
|
||||
|
||||
|
||||
|
||||
-- Sets up a trigger for the given table to automatically set a column called
|
||||
-- `updated_at` whenever the row is modified (unless `updated_at` was included
|
||||
-- in the modified columns)
|
||||
--
|
||||
-- # Example
|
||||
--
|
||||
-- ```sql
|
||||
-- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW());
|
||||
--
|
||||
-- SELECT diesel_manage_updated_at('users');
|
||||
-- ```
|
||||
CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$
|
||||
BEGIN
|
||||
EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s
|
||||
FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$
|
||||
BEGIN
|
||||
IF (
|
||||
NEW IS DISTINCT FROM OLD AND
|
||||
NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at
|
||||
) THEN
|
||||
NEW.updated_at := current_timestamp;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
|
@ -1,3 +0,0 @@
|
|||
DROP TABLE accounts;
|
||||
|
||||
DROP COLLATION case_insensitive;
|
1
migrations/20231018025924_accounts.down.sql
Normal file
1
migrations/20231018025924_accounts.down.sql
Normal file
|
@ -0,0 +1 @@
|
|||
DROP TABLE accounts;
|
|
@ -1,13 +1,7 @@
|
|||
CREATE COLLATION case_insensitive (
|
||||
provider = icu,
|
||||
locale = 'und-u-ks-level2',
|
||||
deterministic = false
|
||||
);
|
||||
|
||||
CREATE TABLE accounts (
|
||||
id SERIAL PRIMARY KEY,
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
|
||||
username VARCHAR(20) NOT NULL COLLATE case_insensitive UNIQUE,
|
||||
username VARCHAR(20) NOT NULL COLLATE NOCASE UNIQUE,
|
||||
gjp2 TEXT NOT NULL, -- argon2 hashed (rubrub uses bcrypt but oh well)
|
||||
password TEXT NOT NULL, -- argon2 hashed (rubrub uses bcrypt but oh well)
|
||||
email VARCHAR(254) NOT NULL,
|
||||
|
@ -25,5 +19,5 @@ CREATE TABLE accounts (
|
|||
twitter_url VARCHAR(20),
|
||||
twitch_url VARCHAR(20),
|
||||
|
||||
created_at TEXT NOT NULL DEFAULT (TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS'))
|
||||
created_at TEXT NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'now'))
|
||||
);
|
|
@ -1,14 +1,18 @@
|
|||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
|
||||
-- if `registered`, use account_id, else, use udid
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
|
||||
-- on a registered account, account_id refers to the
|
||||
-- account ID - however, pre 2.0, instead udid referred
|
||||
-- to the user's UUID or UDID, depending on platform.
|
||||
-- UUID and UDID are unique ids assigned for green
|
||||
-- username users
|
||||
--
|
||||
-- in short, if `registered`, use account_id, else, use udid
|
||||
udid TEXT,
|
||||
account_id INTEGER references accounts(id),
|
||||
registered INTEGER NOT NULL,
|
||||
|
||||
-- idk why but we get weird errors if we use `COLLATE case_insensitive`
|
||||
-- maybe troubleshoot later, this works fine for now.
|
||||
username TEXT NOT NULL, -- COLLATE case_insensitive,
|
||||
username TEXT NOT NULL COLLATE NOCASE,
|
||||
|
||||
stars INTEGER NOT NULL DEFAULT 0,
|
||||
demons INTEGER NOT NULL DEFAULT 0,
|
||||
|
@ -34,8 +38,8 @@ CREATE TABLE users (
|
|||
special INTEGER NOT NULL DEFAULT 0,
|
||||
glow INTEGER NOT NULL DEFAULT 0,
|
||||
|
||||
created_at TEXT NOT NULL DEFAULT (TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS')),
|
||||
last_played TEXT NOT NULL DEFAULT (TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS')),
|
||||
created_at TEXT NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'now')),
|
||||
last_played TEXT NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'now')),
|
||||
|
||||
is_banned INTEGER NOT NULL DEFAULT 0,
|
||||
is_banned_upload INTEGER NOT NULL DEFAULT 0
|
|
@ -1,11 +1,11 @@
|
|||
CREATE TABLE levels (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TEXT NOT NULL DEFAULT (TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS')),
|
||||
modified_at TEXT NOT NULL DEFAULT (TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS')),
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
created_at TEXT NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'now')),
|
||||
modified_at TEXT NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'now')),
|
||||
|
||||
name VARCHAR(20) NOT NULL,
|
||||
user_id INTEGER NOT NULL references users(id),
|
||||
description VARCHAR(140) NOT NULL DEFAULT '',
|
||||
description VARCHAR(140) NOT NULL DEFAULT "",
|
||||
original INTEGER,
|
||||
|
||||
game_version INTEGER NOT NULL,
|
||||
|
@ -16,8 +16,8 @@ CREATE TABLE levels (
|
|||
unlisted INTEGER NOT NULL DEFAULT 0,
|
||||
|
||||
version INTEGER NOT NULL DEFAULT 0,
|
||||
extra_data BYTEA NOT NULL,
|
||||
level_info BYTEA NOT NULL,
|
||||
extra_data BLOB NOT NULL,
|
||||
level_info BLOB NOT NULL,
|
||||
|
||||
editor_time INTEGER NOT NULL,
|
||||
editor_time_copies INTEGER NOT NULL,
|
||||
|
@ -39,4 +39,4 @@ CREATE TABLE levels (
|
|||
featured INTEGER NOT NULL DEFAULT 0,
|
||||
epic INTEGER NOT NULL DEFAULT 0,
|
||||
rated_coins INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue