Working user and link list, (big)restructure

This is now a workspace consisting of:
  * the pslink app (a wasm frontend for the admin interface)
  * the pslink binary
  * shared - modules for communication between the two above.
This commit is contained in:
2021-08-12 15:48:02 +02:00
committed by dietrich
parent 1611cfb9a2
commit fc9b18141f
60 changed files with 2238 additions and 396 deletions
View File
@@ -0,0 +1,31 @@
-- Add up migration script here
DROP TABLE IF EXISTS __diesel_schema_migrations;
-- Add migration script here
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY NOT NULL,
username VARCHAR NOT NULL,
email VARCHAR NOT NULL,
password VARCHAR NOT NULL,
role INTEGER DEFAULT 1 NOT NULL,
UNIQUE(username),
UNIQUE(email)
);
CREATE TABLE IF NOT EXISTS links (
id INTEGER PRIMARY KEY NOT NULL,
title VARCHAR NOT NULL,
target VARCHAR NOT NULL,
code VARCHAR NOT NULL,
author INT NOT NULL,
created_at TIMESTAMP NOT NULL,
FOREIGN KEY (author) REFERENCES users (id),
UNIQUE (code)
);
CREATE TABLE IF NOT EXISTS clicks (
id INTEGER PRIMARY KEY NOT NULL,
link INT NOT NULL,
created_at TIMESTAMP NOT NULL,
FOREIGN KEY (link) REFERENCES links (id)
);
@@ -0,0 +1,4 @@
-- Add migration script here
ALTER TABLE users
ADD COLUMN language Text NOT NULL DEFAULT "en";
@@ -0,0 +1,24 @@
-- Add migration script here
PRAGMA foreign_keys = off;
CREATE TABLE new_clicks (
id INTEGER PRIMARY KEY NOT NULL,
link INT NOT NULL,
created_at TIMESTAMP NOT NULL,
FOREIGN KEY (link) REFERENCES links (id) ON DELETE CASCADE
);
INSERT INTO
new_clicks
SELECT
*
FROM
clicks;
DROP TABLE clicks;
ALTER TABLE
new_clicks RENAME TO clicks;
PRAGMA foreign_keys = on;