Skip to content

Commit cc73fab

Browse files
authored
Merge pull request #3 from WebmasterCamp/tomain
merge main
2 parents 45df3c1 + 560ec81 commit cc73fab

30 files changed

+4179
-446
lines changed

drizzle.config.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
import 'dotenv/config';
2-
import { defineConfig } from 'drizzle-kit';
1+
import type { Config } from 'drizzle-kit';
2+
import * as dotenv from 'dotenv';
3+
dotenv.config();
4+
``
5+
export default {
6+
out: './drizzle',
7+
schema: './drizzle/schema.ts',
8+
// @ts-ignore
9+
dialect: 'postgresql', // 'pg' | 'mysql2' | 'better-sqlite' | 'libsql' | 'turso'
10+
dbCredentials: {
11+
// @ts-ignore
12+
host: process.env.DB_HOST!,
13+
user: process.env.DB_USER!,
14+
password: process.env.DB_PASSWORD!,
15+
database: process.env.DB_NAME!,
16+
ssl: false
17+
}
18+
} satisfies Config;
319

4-
export default defineConfig({
5-
out: './drizzle',
6-
schema: './src/db/schema.ts',
7-
dialect: 'postgresql',
8-
dbCredentials: {
9-
url: process.env.DATABASE_URL!,
10-
},
11-
});

drizzle/0000_red_glorian.sql

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
CREATE TABLE "Category" (
2+
"id" serial PRIMARY KEY NOT NULL,
3+
"name" text NOT NULL,
4+
"description" text,
5+
"app_read" boolean DEFAULT false NOT NULL,
6+
"app_write" boolean DEFAULT false NOT NULL,
7+
"creationdate" timestamp DEFAULT now() NOT NULL,
8+
"isdisable" boolean DEFAULT false NOT NULL,
9+
"ishidden" boolean DEFAULT false NOT NULL,
10+
"totaltopics" integer DEFAULT 0 NOT NULL,
11+
"createby" integer NOT NULL
12+
);
13+
--> statement-breakpoint
14+
CREATE TABLE "Key" (
15+
"id" varchar(255) PRIMARY KEY NOT NULL,
16+
"userId" integer NOT NULL,
17+
"hashedPassword" text
18+
);
19+
--> statement-breakpoint
20+
CREATE TABLE "Log" (
21+
"id" serial PRIMARY KEY NOT NULL,
22+
"action" text NOT NULL,
23+
"who" integer NOT NULL,
24+
"ondate" timestamp DEFAULT now() NOT NULL
25+
);
26+
--> statement-breakpoint
27+
CREATE TABLE "Post" (
28+
"id" serial PRIMARY KEY NOT NULL,
29+
"name" text NOT NULL,
30+
"description" text,
31+
"createby" integer NOT NULL,
32+
"creation_date" timestamp DEFAULT now() NOT NULL,
33+
"last_edited" timestamp NOT NULL,
34+
"app_read" boolean DEFAULT false NOT NULL,
35+
"app_write" boolean DEFAULT false NOT NULL,
36+
"isdisable" boolean DEFAULT false NOT NULL,
37+
"ishidden" boolean DEFAULT false NOT NULL,
38+
"maplocation" text,
39+
"categoryId" integer NOT NULL
40+
);
41+
--> statement-breakpoint
42+
CREATE TABLE "Review" (
43+
"id" serial PRIMARY KEY NOT NULL,
44+
"userid" integer NOT NULL,
45+
"topicid" integer NOT NULL,
46+
"title" text NOT NULL,
47+
"description" text NOT NULL
48+
);
49+
--> statement-breakpoint
50+
CREATE TABLE "Session" (
51+
"id" varchar(255) PRIMARY KEY NOT NULL,
52+
"userId" integer NOT NULL,
53+
"expiresAt" timestamp NOT NULL
54+
);
55+
--> statement-breakpoint
56+
CREATE TABLE "Stargazing" (
57+
"id" serial PRIMARY KEY NOT NULL,
58+
"title" text NOT NULL,
59+
"description" text,
60+
"lat" real NOT NULL,
61+
"long" real NOT NULL
62+
);
63+
--> statement-breakpoint
64+
CREATE TABLE "User" (
65+
"id" serial PRIMARY KEY NOT NULL,
66+
"Firstname" text NOT NULL,
67+
"Lastname" text NOT NULL,
68+
"username" text NOT NULL,
69+
"email" text NOT NULL,
70+
"hashedpass" text NOT NULL,
71+
"description" text,
72+
"isbanned" boolean DEFAULT false NOT NULL
73+
);
74+
--> statement-breakpoint
75+
CREATE UNIQUE INDEX "name_idx" ON "Category" USING btree ("name");--> statement-breakpoint
76+
CREATE UNIQUE INDEX "username_idx" ON "User" USING btree ("username");--> statement-breakpoint
77+
CREATE UNIQUE INDEX "email_idx" ON "User" USING btree ("email");

drizzle/0001_lame_master_chief.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
CREATE TABLE "categories" (
2+
"id" serial PRIMARY KEY NOT NULL,
3+
"name" text NOT NULL,
4+
"description" text,
5+
CONSTRAINT "categories_unique_name_id" UNIQUE("id","name"),
6+
CONSTRAINT "categories_name_key" UNIQUE("name")
7+
);
8+
--> statement-breakpoint
9+
CREATE TABLE "hotel" (
10+
"type" text NOT NULL,
11+
"id" serial PRIMARY KEY NOT NULL,
12+
"name" text NOT NULL,
13+
"description" text NOT NULL,
14+
"maplocation" double precision NOT NULL,
15+
"image" text NOT NULL,
16+
"provice" text NOT NULL,
17+
"price" real NOT NULL,
18+
"darkindex" real NOT NULL
19+
);
20+
--> statement-breakpoint
21+
ALTER TABLE "Category" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint
22+
ALTER TABLE "Post" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint
23+
DROP TABLE "Category" CASCADE;--> statement-breakpoint
24+
DROP TABLE "Post" CASCADE;--> statement-breakpoint
25+
DROP INDEX "username_idx";--> statement-breakpoint
26+
DROP INDEX "email_idx";--> statement-breakpoint
27+
ALTER TABLE "hotel" ADD CONSTRAINT "hotel_type_fk" FOREIGN KEY ("type") REFERENCES "public"."categories"("name") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
28+
CREATE INDEX "categories_index_0" ON "categories" USING btree ("id" int4_ops,"name" text_ops);--> statement-breakpoint
29+
CREATE UNIQUE INDEX "username_idx" ON "User" USING btree ("username" text_ops);--> statement-breakpoint
30+
CREATE UNIQUE INDEX "email_idx" ON "User" USING btree ("email" text_ops);

0 commit comments

Comments
 (0)