Skip to content

Commit dcf1042

Browse files
committed
insert questions schema
1 parent fc3bc9f commit dcf1042

File tree

4 files changed

+98
-3
lines changed

4 files changed

+98
-3
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CREATE TABLE IF NOT EXISTS "questions" (
2+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3+
"title" varchar(255) NOT NULL,
4+
"difficulty" varchar(50) NOT NULL,
5+
"topic" varchar(100) NOT NULL,
6+
"description" text NOT NULL,
7+
"created_at" timestamp (6) with time zone DEFAULT now(),
8+
"updated_at" timestamp (6) with time zone DEFAULT now()
9+
);
10+
--> statement-breakpoint
11+
DROP TABLE "tableName";
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"id": "7aa662fc-c03f-4252-a1e1-15369fe3c1b0",
3+
"prevId": "bfb0f47d-1ebe-47d4-b979-8fe9d6305cd4",
4+
"version": "7",
5+
"dialect": "postgresql",
6+
"tables": {
7+
"public.questions": {
8+
"name": "questions",
9+
"schema": "",
10+
"columns": {
11+
"id": {
12+
"name": "id",
13+
"type": "uuid",
14+
"primaryKey": true,
15+
"notNull": true,
16+
"default": "gen_random_uuid()"
17+
},
18+
"title": {
19+
"name": "title",
20+
"type": "varchar(255)",
21+
"primaryKey": false,
22+
"notNull": true
23+
},
24+
"difficulty": {
25+
"name": "difficulty",
26+
"type": "varchar(50)",
27+
"primaryKey": false,
28+
"notNull": true
29+
},
30+
"topic": {
31+
"name": "topic",
32+
"type": "varchar(100)",
33+
"primaryKey": false,
34+
"notNull": true
35+
},
36+
"description": {
37+
"name": "description",
38+
"type": "text",
39+
"primaryKey": false,
40+
"notNull": true
41+
},
42+
"created_at": {
43+
"name": "created_at",
44+
"type": "timestamp (6) with time zone",
45+
"primaryKey": false,
46+
"notNull": false,
47+
"default": "now()"
48+
},
49+
"updated_at": {
50+
"name": "updated_at",
51+
"type": "timestamp (6) with time zone",
52+
"primaryKey": false,
53+
"notNull": false,
54+
"default": "now()"
55+
}
56+
},
57+
"indexes": {},
58+
"foreignKeys": {},
59+
"compositePrimaryKeys": {},
60+
"uniqueConstraints": {}
61+
}
62+
},
63+
"enums": {},
64+
"schemas": {},
65+
"sequences": {},
66+
"_meta": {
67+
"columns": {},
68+
"schemas": {},
69+
"tables": {}
70+
}
71+
}

backend/question/drizzle/meta/_journal.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
"when": 1726382290778,
99
"tag": "0000_initial_schema",
1010
"breakpoints": true
11+
},
12+
{
13+
"idx": 1,
14+
"version": "7",
15+
"when": 1727316962366,
16+
"tag": "0001_new_questions_table",
17+
"breakpoints": true
1118
}
1219
]
1320
}
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
import { pgTable, uuid } from 'drizzle-orm/pg-core';
1+
import { pgTable, uuid, varchar, text, timestamp } from 'drizzle-orm/pg-core';
22

3-
export const tableName = pgTable('tableName', {
4-
id: uuid('id').unique().primaryKey().defaultRandom(),
3+
export const questions = pgTable('questions', {
4+
id: uuid('id').primaryKey().defaultRandom(),
5+
title: varchar('title', { length: 255 }).notNull(),
6+
difficulty: varchar('difficulty', { length: 50 }).notNull(),
7+
topic: varchar('topic', { length: 100 }).notNull(),
8+
description: text('description').notNull(),
9+
createdAt: timestamp('created_at', { precision: 6, withTimezone: true }).defaultNow(),
10+
updatedAt: timestamp('updated_at', { precision: 6, withTimezone: true }).defaultNow(),
511
});

0 commit comments

Comments
 (0)