Skip to content

Commit

Permalink
Add delete tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-walker committed Apr 13, 2024
1 parent 69b2d2e commit 4d5ed8a
Show file tree
Hide file tree
Showing 10 changed files with 522 additions and 16 deletions.
24 changes: 12 additions & 12 deletions worker/migrations/0000_fair_donald_blake.sql
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
CREATE TABLE short_link_paste (
CREATE TABLE `short_link_paste` (
`short_link_id` text PRIMARY KEY NOT NULL,
`code` text NOT NULL,
`language` text,
FOREIGN KEY (`short_link_id`) REFERENCES short_link(`id`)
FOREIGN KEY (`short_link_id`) REFERENCES `short_link`(`id`) ON UPDATE no action ON DELETE no action
);

CREATE TABLE short_link_upload (
--> statement-breakpoint
CREATE TABLE `short_link_upload` (
`short_link_id` text PRIMARY KEY NOT NULL,
`filename` text NOT NULL,
`size` integer NOT NULL,
`hash` text NOT NULL,
FOREIGN KEY (`short_link_id`) REFERENCES short_link(`id`)
FOREIGN KEY (`short_link_id`) REFERENCES `short_link`(`id`) ON UPDATE no action ON DELETE no action
);

CREATE TABLE short_link_url (
--> statement-breakpoint
CREATE TABLE `short_link_url` (
`short_link_id` text PRIMARY KEY NOT NULL,
`url` text NOT NULL,
FOREIGN KEY (`short_link_id`) REFERENCES short_link(`id`)
FOREIGN KEY (`short_link_id`) REFERENCES `short_link`(`id`) ON UPDATE no action ON DELETE no action
);

CREATE TABLE short_link (
--> statement-breakpoint
CREATE TABLE `short_link` (
`id` text PRIMARY KEY NOT NULL,
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
`updated_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
`created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,
`updated_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,
`expires_at` integer,
`type` text NOT NULL
);
1 change: 1 addition & 0 deletions worker/migrations/0001_romantic_strong_guy.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE short_link ADD `delete_token` text(128);
192 changes: 192 additions & 0 deletions worker/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
{
"version": "5",
"dialect": "sqlite",
"id": "5c571eee-f9a2-498e-b1a7-6043b91b9b2b",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"short_link_paste": {
"name": "short_link_paste",
"columns": {
"short_link_id": {
"name": "short_link_id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"code": {
"name": "code",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"language": {
"name": "language",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"short_link_paste_short_link_id_short_link_id_fk": {
"name": "short_link_paste_short_link_id_short_link_id_fk",
"tableFrom": "short_link_paste",
"tableTo": "short_link",
"columnsFrom": [
"short_link_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"short_link_upload": {
"name": "short_link_upload",
"columns": {
"short_link_id": {
"name": "short_link_id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"filename": {
"name": "filename",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"size": {
"name": "size",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"hash": {
"name": "hash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"short_link_upload_short_link_id_short_link_id_fk": {
"name": "short_link_upload_short_link_id_short_link_id_fk",
"tableFrom": "short_link_upload",
"tableTo": "short_link",
"columnsFrom": [
"short_link_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"short_link_url": {
"name": "short_link_url",
"columns": {
"short_link_id": {
"name": "short_link_id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"short_link_url_short_link_id_short_link_id_fk": {
"name": "short_link_url_short_link_id_short_link_id_fk",
"tableFrom": "short_link_url",
"tableTo": "short_link",
"columnsFrom": [
"short_link_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"short_link": {
"name": "short_link",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
}
Loading

0 comments on commit 4d5ed8a

Please sign in to comment.