mirror of
https://github.com/eliasrenman/url-shortener.git
synced 2026-03-16 20:16:06 +01:00
first commit
This commit is contained in:
4
migrations/2025-03-16-110640_url_entry/down.sql
Normal file
4
migrations/2025-03-16-110640_url_entry/down.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TRIGGER url_update_at_trigger;
|
||||
|
||||
DROP TABLE url;
|
||||
19
migrations/2025-03-16-110640_url_entry/up.sql
Normal file
19
migrations/2025-03-16-110640_url_entry/up.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE urls (
|
||||
url TEXT PRIMARY KEY NOT NULL,
|
||||
destination_url TEXT NOT NULL,
|
||||
ttl DATETIME,
|
||||
owned_by TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TRIGGER urls_update_at_trigger AFTER
|
||||
UPDATE On urls BEGIN
|
||||
UPDATE urls
|
||||
SET
|
||||
updated_at = STRFTIME ('%Y-%m-%d %H:%M:%f', 'NOW')
|
||||
WHERE
|
||||
URLS = NEW.URLS;
|
||||
|
||||
END;
|
||||
Reference in New Issue
Block a user