Skip to content

Commit

Permalink
Merge pull request #116 from quantum-brackets/admin-resources
Browse files Browse the repository at this point in the history
Admin resources
  • Loading branch information
henzyd authored Dec 29, 2024
2 parents 587a9cb + 2a43508 commit b56ac99
Show file tree
Hide file tree
Showing 26 changed files with 438 additions and 2,108 deletions.
40 changes: 33 additions & 7 deletions migrations/0000_misty_blob.sql → migrations/0000_busy_sabra.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,21 @@ CREATE TABLE IF NOT EXISTS "locations" (
"city" varchar(100) NOT NULL,
"description" varchar,
"updated_at" timestamp,
"created_at" timestamp DEFAULT now()
"created_at" timestamp DEFAULT now(),
CONSTRAINT "unique_name_state_city" UNIQUE("name","state","city")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "medias" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"url" varchar NOT NULL,
"type" varchar NOT NULL,
"file_type" varchar NOT NULL,
"entity_type" varchar NOT NULL,
"entity_id" uuid NOT NULL,
"mime_type" varchar(100),
"size" integer,
"updated_at" timestamp,
"created_at" timestamp DEFAULT now(),
"metadata" jsonb
"metadata" jsonb,
"user_id" uuid,
"location_id" uuid,
"resource_id" uuid
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "otps" (
Expand Down Expand Up @@ -101,10 +103,10 @@ CREATE TABLE IF NOT EXISTS "resource_rules" (
CREATE TABLE IF NOT EXISTS "resources" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"name" varchar(300) NOT NULL,
"location" varchar(300) NOT NULL,
"type" varchar NOT NULL,
"description" varchar NOT NULL,
"status" varchar DEFAULT 'draft',
"location_id" uuid NOT NULL,
"thumbnail" varchar NOT NULL,
"rating" numeric,
"address" varchar,
Expand Down Expand Up @@ -158,6 +160,24 @@ EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "medias" ADD CONSTRAINT "medias_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "medias" ADD CONSTRAINT "medias_location_id_locations_id_fk" FOREIGN KEY ("location_id") REFERENCES "public"."locations"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "medias" ADD CONSTRAINT "medias_resource_id_resources_id_fk" FOREIGN KEY ("resource_id") REFERENCES "public"."resources"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "prices" ADD CONSTRAINT "prices_region_id_regions_id_fk" FOREIGN KEY ("region_id") REFERENCES "public"."regions"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
Expand Down Expand Up @@ -193,3 +213,9 @@ DO $$ BEGIN
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "resources" ADD CONSTRAINT "resources_location_id_locations_id_fk" FOREIGN KEY ("location_id") REFERENCES "public"."locations"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
1 change: 0 additions & 1 deletion migrations/0001_bouncy_xavin.sql

This file was deleted.

1 change: 1 addition & 0 deletions migrations/0001_easy_rattler.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "locations" ADD COLUMN "deleted_at" timestamp;
1 change: 0 additions & 1 deletion migrations/0002_flaky_gateway.sql

This file was deleted.

28 changes: 0 additions & 28 deletions migrations/0003_little_the_call.sql

This file was deleted.

130 changes: 100 additions & 30 deletions migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "36d788aa-0f6a-4bc7-aab3-a875b4e89c19",
"id": "05a78cc5-8440-4019-8234-5884d04b7ffa",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
Expand Down Expand Up @@ -296,7 +296,17 @@
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
"uniqueConstraints": {
"unique_name_state_city": {
"name": "unique_name_state_city",
"nullsNotDistinct": false,
"columns": [
"name",
"state",
"city"
]
}
}
},
"public.medias": {
"name": "medias",
Expand All @@ -315,29 +325,17 @@
"primaryKey": false,
"notNull": true
},
"type": {
"name": "type",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"file_type": {
"name": "file_type",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"entity_type": {
"name": "entity_type",
"type": "varchar",
"mime_type": {
"name": "mime_type",
"type": "varchar(100)",
"primaryKey": false,
"notNull": true
"notNull": false
},
"entity_id": {
"name": "entity_id",
"type": "uuid",
"size": {
"name": "size",
"type": "integer",
"primaryKey": false,
"notNull": true
"notNull": false
},
"updated_at": {
"name": "updated_at",
Expand All @@ -357,10 +355,68 @@
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
"user_id": {
"name": "user_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"location_id": {
"name": "location_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"resource_id": {
"name": "resource_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"foreignKeys": {
"medias_user_id_users_id_fk": {
"name": "medias_user_id_users_id_fk",
"tableFrom": "medias",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"medias_location_id_locations_id_fk": {
"name": "medias_location_id_locations_id_fk",
"tableFrom": "medias",
"tableTo": "locations",
"columnsFrom": [
"location_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"medias_resource_id_resources_id_fk": {
"name": "medias_resource_id_resources_id_fk",
"tableFrom": "medias",
"tableTo": "resources",
"columnsFrom": [
"resource_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
Expand Down Expand Up @@ -680,12 +736,6 @@
"primaryKey": false,
"notNull": true
},
"location": {
"name": "location",
"type": "varchar(300)",
"primaryKey": false,
"notNull": true
},
"type": {
"name": "type",
"type": "varchar",
Expand All @@ -705,6 +755,12 @@
"notNull": false,
"default": "'draft'"
},
"location_id": {
"name": "location_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"thumbnail": {
"name": "thumbnail",
"type": "varchar",
Expand Down Expand Up @@ -738,7 +794,21 @@
}
},
"indexes": {},
"foreignKeys": {},
"foreignKeys": {
"resources_location_id_locations_id_fk": {
"name": "resources_location_id_locations_id_fk",
"tableFrom": "resources",
"tableTo": "locations",
"columnsFrom": [
"location_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
Expand Down
Loading

0 comments on commit b56ac99

Please sign in to comment.