Skip to content

Commit

Permalink
feat: user account (#20)
Browse files Browse the repository at this point in the history
* feat: add github login

* add github login

* add migrate and build at the same time
  • Loading branch information
invisal authored Mar 12, 2024
1 parent 27ad343 commit 24819fd
Show file tree
Hide file tree
Showing 21 changed files with 7,389 additions and 1,866 deletions.
12 changes: 12 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { env } from "@/env";
import type { Config } from "drizzle-kit";

export default {
schema: "./src/db/schema.ts",
out: "./drizzle",
driver: "turso",
dbCredentials: {
url: env.DATABASE_URL,
authToken: env.DATABASE_AUTH_TOKEN,
},
} satisfies Config;
27 changes: 27 additions & 0 deletions drizzle/0000_solid_scream.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
CREATE TABLE `user` (
`id` text PRIMARY KEY NOT NULL,
`name` text,
`picture` text,
`created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--> statement-breakpoint
CREATE TABLE `user_auth` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text,
`provider` text,
`provider_id` text,
`created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--> statement-breakpoint
CREATE TABLE `user_session` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`auth_id` text,
`user_agent` text,
`expires_at` blob NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `user_auth_provider_provider_id_unique` ON `user_auth` (`provider`,`provider_id`);--> statement-breakpoint
CREATE INDEX `user_session_expire_idx` ON `user_session` (`expires_at`);--> statement-breakpoint
CREATE INDEX `user_session_auth_id_idx` ON `user_session` (`auth_id`);
179 changes: 179 additions & 0 deletions drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"version": "5",
"dialect": "sqlite",
"id": "842060cb-8a3f-4721-aeb8-909365440ca3",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"picture": {
"name": "picture",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user_auth": {
"name": "user_auth",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"provider_id": {
"name": "provider_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
}
},
"indexes": {
"user_auth_provider_provider_id_unique": {
"name": "user_auth_provider_provider_id_unique",
"columns": [
"provider",
"provider_id"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user_session": {
"name": "user_session",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"auth_id": {
"name": "auth_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"user_agent": {
"name": "user_agent",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "blob",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"user_session_expire_idx": {
"name": "user_session_expire_idx",
"columns": [
"expires_at"
],
"isUnique": false
},
"user_session_auth_id_idx": {
"name": "user_session_auth_id_idx",
"columns": [
"auth_id"
],
"isUnique": false
}
},
"foreignKeys": {
"user_session_user_id_user_id_fk": {
"name": "user_session_user_id_user_id_fk",
"tableFrom": "user_session",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
}
13 changes: 13 additions & 0 deletions drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "5",
"dialect": "sqlite",
"entries": [
{
"idx": 0,
"version": "5",
"when": 1710049140295,
"tag": "0000_solid_scream",
"breakpoints": true
}
]
}
Loading

0 comments on commit 24819fd

Please sign in to comment.