Have got uploads working
This commit is contained in:
parent
97112d99dd
commit
6b697e008f
20 changed files with 751 additions and 7 deletions
14
sql/queries/pending_uploads.sql
Normal file
14
sql/queries/pending_uploads.sql
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
-- name: SelectPendingUploadByGUID :one
|
||||
SELECT * FROM pending_uploads WHERE guid = ? LIMIT 1;
|
||||
|
||||
-- name: InsertPendingUpload :one
|
||||
INSERT INTO pending_uploads (
|
||||
site_id,
|
||||
guid,
|
||||
user_id,
|
||||
filename,
|
||||
file_size,
|
||||
mime_type,
|
||||
upload_started_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING id;
|
||||
22
sql/queries/uploads.sql
Normal file
22
sql/queries/uploads.sql
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
-- name: SelectUploadsOfSite :many
|
||||
SELECT * FROM uploads WHERE site_id = ? ORDER BY created_at DESC;
|
||||
|
||||
-- name: SelectUploadByID :one
|
||||
SELECT * FROM uploads WHERE id = ?;
|
||||
|
||||
-- name: InsertUpload :exec
|
||||
INSERT INTO uploads (
|
||||
site_id,
|
||||
guid,
|
||||
mime_type,
|
||||
filename,
|
||||
created_at,
|
||||
alt
|
||||
) VALUES (?, ?, ?, ?, ?, ?)
|
||||
RETURNING id;
|
||||
|
||||
-- name: UpdateUpload :exec
|
||||
UPDATE uploads SET alt = ? WHERE id = ?;
|
||||
|
||||
-- name: DeleteUpload :exec
|
||||
DELETE FROM uploads WHERE id = ?;
|
||||
27
sql/schema/02_upload.up.sql
Normal file
27
sql/schema/02_upload.up.sql
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
CREATE TABLE uploads (
|
||||
id SERIAL PRIMARY KEY,
|
||||
site_id INT NOT NULL,
|
||||
guid TEXT NOT NULL,
|
||||
mime_type TEXT NOT NULL,
|
||||
filename TEXT NOT NULL,
|
||||
alt TEXT NOT NULL,
|
||||
created_at INT NOT NULL,
|
||||
|
||||
FOREIGN KEY (site_id) REFERENCES sites (id) ON DELETE CASCADE
|
||||
);
|
||||
CREATE INDEX idx_uploads_site ON uploads (site_id);
|
||||
CREATE UNIQUE INDEX idx_uploads_guid ON sites (guid);
|
||||
|
||||
CREATE TABLE pending_uploads (
|
||||
id SERIAL PRIMARY KEY,
|
||||
site_id INT NOT NULL,
|
||||
guid TEXT NOT NULL,
|
||||
user_id INT NOT NULL,
|
||||
filename TEXT NOT NULL,
|
||||
file_size INT NOT NULL,
|
||||
mime_type TEXT NOT NULL,
|
||||
upload_started_at INT NOT NULL,
|
||||
FOREIGN KEY (site_id) REFERENCES sites (id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
|
||||
);
|
||||
CREATE UNIQUE INDEX idx_pending_uploads_guid ON pending_uploads (guid);
|
||||
Loading…
Add table
Add a link
Reference in a new issue