summaryrefslogtreecommitdiff
path: root/migrations/20240929013644_token_id.sql
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-09-30 21:41:36 -0400
committerKit La Touche <kit@transneptune.net>2024-09-30 21:41:36 -0400
commitc0fead957c6433be1ddfbbe8a55276a4aa8fc4df (patch)
treefb8a12519e86628349d8070a193d3ce75a82e1a8 /migrations/20240929013644_token_id.sql
parenta6a170ab5320d9ef0a2e007ac3ab75edee574fef (diff)
parent6c054c5b8d43a818ccfa9087960dc19b286e6bb7 (diff)
Merge branch 'main' into feature-frontend
Diffstat (limited to 'migrations/20240929013644_token_id.sql')
-rw-r--r--migrations/20240929013644_token_id.sql29
1 files changed, 29 insertions, 0 deletions
diff --git a/migrations/20240929013644_token_id.sql b/migrations/20240929013644_token_id.sql
new file mode 100644
index 0000000..ad4d8b4
--- /dev/null
+++ b/migrations/20240929013644_token_id.sql
@@ -0,0 +1,29 @@
+alter table token
+rename to old_token;
+
+create table token (
+ id text
+ not null
+ primary key,
+ secret text
+ not null
+ unique,
+ login text
+ not null,
+ issued_at text
+ not null,
+ last_used_at text
+ not null,
+ foreign key (login)
+ references login (id)
+);
+
+insert into token
+select
+ 'T' || lower(hex(randomblob(8))) as id,
+ *
+from old_token;
+
+drop table old_token;
+
+create index token_issued_at on token (issued_at);