mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-26 22:19:32 -06:00
Libraries
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
CREATE TABLE users(
|
||||
id SERIAL,
|
||||
id SERIAL PRIMARY KEY,
|
||||
display_name TEXT NOT NULL,
|
||||
username TEXT NOT NULL,
|
||||
password_hash TEXT NOT NULL,
|
||||
deleted TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX unique_username ON users(username) WHERE deleted IS NULL;
|
||||
CREATE UNIQUE INDEX unique_username ON users(username);
|
||||
1
sql/migrations/003_libraries.down.sql
Normal file
1
sql/migrations/003_libraries.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE libraries;
|
||||
6
sql/migrations/003_libraries.up.sql
Normal file
6
sql/migrations/003_libraries.up.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE libraries(
|
||||
id uuid PRIMARY KEY,
|
||||
owner SERIAL NOT NULL REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
display_name TEXT NOT NULL,
|
||||
deleted TIMESTAMP
|
||||
);
|
||||
9
sql/queries/libraries.sql
Normal file
9
sql/queries/libraries.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- name: LibraryById :one
|
||||
SELECT * from libraries where id = $1;
|
||||
|
||||
-- name: CreateLibrary :exec
|
||||
INSERT INTO libraries(
|
||||
id, owner, display_name
|
||||
) VALUES(
|
||||
$1, $2, $3
|
||||
);
|
||||
@@ -1,9 +1,6 @@
|
||||
-- name: ResourceById :one
|
||||
SELECT * from resources WHERE id = $1;
|
||||
|
||||
-- name: LibraryByName :one
|
||||
SELECT * from resources WHERE deleted IS NULL AND parent IS NULL AND name = $1;
|
||||
|
||||
-- name: CreateResource :exec
|
||||
INSERT INTO resources(
|
||||
id, parent, name, dir, created, modified
|
||||
|
||||
Reference in New Issue
Block a user