Skip to content

Commit

Permalink
chore: create db schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Kan-A-Pesh committed Oct 25, 2024
1 parent f2c91dd commit 54eb454
Show file tree
Hide file tree
Showing 9 changed files with 458 additions and 16 deletions.
4 changes: 0 additions & 4 deletions database/migrations/0000_light_tinkerer.sql

This file was deleted.

48 changes: 48 additions & 0 deletions database/migrations/0000_organic_fantastic_four.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
CREATE TABLE IF NOT EXISTS "acquired" (
"user_uuid" uuid PRIMARY KEY NOT NULL,
"challenge_id" serial PRIMARY KEY NOT NULL,
"created_by" serial NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "challenges" (
"id" serial PRIMARY KEY NOT NULL,
"club_id" serial NOT NULL,
"score" integer NOT NULL,
"name" text NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "clubs" (
"id" serial PRIMARY KEY NOT NULL,
"avatar_url" text NOT NULL,
"name" text NOT NULL,
"description" text NOT NULL,
"daily_date" date NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "granters" (
"id" serial PRIMARY KEY NOT NULL,
"club_id" serial NOT NULL,
"email" text NOT NULL,
"password" text NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "users" (
"uuid" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"club_id" serial NOT NULL,
"email" text NOT NULL,
"hashpass" text NOT NULL,
"username" text NOT NULL,
"quote" text,
"updated_at" timestamp DEFAULT now() NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "name_unique_idx" ON "clubs" USING btree ("name");--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "email_unique_idx" ON "users" USING btree ("email");--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "username_unique_idx" ON "users" USING btree ("username");
278 changes: 273 additions & 5 deletions database/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,54 @@
{
"id": "85674a8b-3f8c-476f-9ce2-8635c80b2d04",
"id": "0e004108-39e1-4d32-b380-d66778f5ed70",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.users": {
"name": "users",
"public.acquired": {
"name": "acquired",
"schema": "",
"columns": {
"user_uuid": {
"name": "user_uuid",
"type": "uuid",
"primaryKey": true,
"notNull": true
},
"challenge_id": {
"name": "challenge_id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"created_by": {
"name": "created_by",
"type": "serial",
"primaryKey": false,
"notNull": true
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"public.challenges": {
"name": "challenges",
"schema": "",
"columns": {
"id": {
Expand All @@ -14,18 +57,243 @@
"primaryKey": true,
"notNull": true
},
"first_name": {
"name": "first_name",
"club_id": {
"name": "club_id",
"type": "serial",
"primaryKey": false,
"notNull": true
},
"score": {
"name": "score",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"public.clubs": {
"name": "clubs",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"avatar_url": {
"name": "avatar_url",
"type": "text",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": true
},
"daily_date": {
"name": "daily_date",
"type": "date",
"primaryKey": false,
"notNull": true
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"name_unique_idx": {
"name": "name_unique_idx",
"columns": [
{
"expression": "name",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"public.granters": {
"name": "granters",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"club_id": {
"name": "club_id",
"type": "serial",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"public.users": {
"name": "users",
"schema": "",
"columns": {
"uuid": {
"name": "uuid",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"club_id": {
"name": "club_id",
"type": "serial",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"hashpass": {
"name": "hashpass",
"type": "text",
"primaryKey": false,
"notNull": true
},
"username": {
"name": "username",
"type": "text",
"primaryKey": false,
"notNull": true
},
"quote": {
"name": "quote",
"type": "text",
"primaryKey": false,
"notNull": false
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"email_unique_idx": {
"name": "email_unique_idx",
"columns": [
{
"expression": "email",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"username_unique_idx": {
"name": "username_unique_idx",
"columns": [
{
"expression": "username",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"enums": {},
Expand Down
4 changes: 2 additions & 2 deletions database/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{
"idx": 0,
"version": "7",
"when": 1729680286443,
"tag": "0000_light_tinkerer",
"when": 1729840120930,
"tag": "0000_organic_fantastic_four",
"breakpoints": true
}
]
Expand Down
Loading

0 comments on commit 54eb454

Please sign in to comment.