Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions drizzle/migrations/0008_wooden_purple_man.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE "schedule" DROP CONSTRAINT "schedule_station_origin_id_station_id_fk";
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "schedule" ADD CONSTRAINT "schedule_station_origin_id_station_id_fk" FOREIGN KEY ("station_origin_id") REFERENCES "public"."station"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
323 changes: 323 additions & 0 deletions drizzle/migrations/meta/0008_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,323 @@
{
"id": "ae343a69-44a3-4c74-9916-0e7ac4f8f116",
"prevId": "511ffc79-573f-46fb-adaf-1de89c7f7d69",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.station": {
"name": "station",
"schema": "",
"columns": {
"uid": {
"name": "uid",
"type": "text",
"primaryKey": true,
"notNull": true
},
"id": {
"name": "id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"type": {
"name": "type",
"type": "station_type",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"metadata": {
"name": "metadata",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"station_uidx": {
"name": "station_uidx",
"columns": [
{
"expression": "uid",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"station_idx": {
"name": "station_idx",
"columns": [
{
"expression": "id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"station_type_idx": {
"name": "station_type_idx",
"columns": [
{
"expression": "type",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"station_uid_unique": {
"name": "station_uid_unique",
"nullsNotDistinct": false,
"columns": [
"uid"
]
},
"station_id_unique": {
"name": "station_id_unique",
"nullsNotDistinct": false,
"columns": [
"id"
]
}
}
},
"public.schedule": {
"name": "schedule",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"station_id": {
"name": "station_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"station_origin_id": {
"name": "station_origin_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"station_destination_id": {
"name": "station_destination_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"train_id": {
"name": "train_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"line": {
"name": "line",
"type": "text",
"primaryKey": false,
"notNull": true
},
"route": {
"name": "route",
"type": "text",
"primaryKey": false,
"notNull": true
},
"departs_at": {
"name": "departs_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"arrives_at": {
"name": "arrives_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"metadata": {
"name": "metadata",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"schedule_idx": {
"name": "schedule_idx",
"columns": [
{
"expression": "id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"schedule_station_idx": {
"name": "schedule_station_idx",
"columns": [
{
"expression": "station_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"schedule_train_idx": {
"name": "schedule_train_idx",
"columns": [
{
"expression": "train_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"schedule_station_id_station_id_fk": {
"name": "schedule_station_id_station_id_fk",
"tableFrom": "schedule",
"tableTo": "station",
"columnsFrom": [
"station_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"schedule_station_origin_id_station_id_fk": {
"name": "schedule_station_origin_id_station_id_fk",
"tableFrom": "schedule",
"tableTo": "station",
"columnsFrom": [
"station_origin_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"schedule_station_destination_id_station_id_fk": {
"name": "schedule_station_destination_id_station_id_fk",
"tableFrom": "schedule",
"tableTo": "station",
"columnsFrom": [
"station_destination_id"
],
"columnsTo": [
"id"
],
"onDelete": "set null",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"schedule_id_unique": {
"name": "schedule_id_unique",
"nullsNotDistinct": false,
"columns": [
"id"
]
}
}
}
},
"enums": {
"public.station_type": {
"name": "station_type",
"schema": "public",
"values": [
"KRL",
"MRT",
"LRT",
"LOCAL"
]
}
},
"schemas": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
7 changes: 7 additions & 0 deletions drizzle/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
"when": 1732445107060,
"tag": "0007_naive_pepper_potts",
"breakpoints": true
},
{
"idx": 8,
"version": "7",
"when": 1743344871226,
"tag": "0008_wooden_purple_man",
"breakpoints": true
}
]
}
6 changes: 3 additions & 3 deletions src/db/schema/schedule.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export const scheduleTable = pgTable(
onDelete: "cascade",
}),
station_origin_id: text("station_origin_id")
.notNull()
.references(() => stationTable.id, {
onDelete: "set null",
})
.notNull(),
onDelete: "cascade",
}),
station_destination_id: text("station_destination_id")
.references(() => stationTable.id, {
onDelete: "set null",
Expand Down