From 1a049d119309e335554a8f9924140b2f695deca0 Mon Sep 17 00:00:00 2001 From: juan Date: Mon, 10 Nov 2025 19:25:17 +0100 Subject: [PATCH] feat: restructure database schema and remove obsolete migrations --- .env | 2 +- src/integrations/drizzle/db/schema.ts | 191 ++--- .../migrations/0000_talented_doorman.sql | 5 - .../migrations/0001_nice_gargoyle.sql | 11 - .../migrations/0002_bouncy_apocalypse.sql | 36 - .../supabase/migrations/0002_init.sql | 68 ++ .../migrations/meta/0000_snapshot.json | 50 -- .../migrations/meta/0001_snapshot.json | 125 ---- .../migrations/meta/0002_snapshot.json | 697 ++++++++++-------- .../supabase/migrations/meta/_journal.json | 38 +- 10 files changed, 578 insertions(+), 645 deletions(-) delete mode 100644 src/integrations/supabase/migrations/0000_talented_doorman.sql delete mode 100644 src/integrations/supabase/migrations/0001_nice_gargoyle.sql delete mode 100644 src/integrations/supabase/migrations/0002_bouncy_apocalypse.sql create mode 100644 src/integrations/supabase/migrations/0002_init.sql delete mode 100644 src/integrations/supabase/migrations/meta/0000_snapshot.json delete mode 100644 src/integrations/supabase/migrations/meta/0001_snapshot.json diff --git a/.env b/.env index 2d74d2a..0ed2204 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ SUPABASE_URL="https://qsssikzgwomudkwfmgad.supabase.co" # DATABASE_URL="postgresql://postgres.qsssikzgwomudkwfmgad:etrTXNz3ZOwaLJmT@aws-0-eu-north-1.pooler.supabase.com:6543/postgres" -DATABASE_URL="postgresql://postgres.qsssikzgwomudkwfmgad:Wrongly1-Untimed0-Peculiar0-Unlikable7-Cubbyhole8@aws-0-eu-north-1.pooler.supabase.com:6543/postgre" +DATABASE_URL="postgresql://postgres.qsssikzgwomudkwfmgad:Wrongly1-Untimed0-Peculiar0-Unlikable7-Cubbyhole8@aws-0-eu-north-1.pooler.supabase.com:6543/postgres" APIKEY_MAPS="AIzaSyAwfOShBqkBcS46WqmlsIVWQJ8gpdOPk_4" SUPABASE_ANON_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFzc3Npa3pnd29tdWRrd2ZtZ2FkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQzMjY1NTQsImV4cCI6MjA2OTkwMjU1NH0.BTSscdTcPP1GVmMB-H5caLpWsfuAw1V6mXiqogF8TjU" \ No newline at end of file diff --git a/src/integrations/drizzle/db/schema.ts b/src/integrations/drizzle/db/schema.ts index 9412d91..21e1c1f 100644 --- a/src/integrations/drizzle/db/schema.ts +++ b/src/integrations/drizzle/db/schema.ts @@ -1,8 +1,9 @@ import { sql } from "drizzle-orm" import { - doublePrecision, - foreignKey, + boolean, + decimal, integer, + jsonb, pgPolicy, pgTable, serial, @@ -12,120 +13,122 @@ import { } from "drizzle-orm/pg-core" import { authenticatedRole, authUsers } from "drizzle-orm/supabase" -export const users = pgTable("demo", { - id: serial("id").primaryKey(), - fullName: text("full_name"), - phone: varchar("phone", { length: 256 }) -}) +// === drones === +export const drones = pgTable("drones", { + id: serial("id").primaryKey().notNull(), + model: varchar("model", { length: 100 }), + brand: varchar("brand", { length: 100 }), + type: jsonb("type") +}).enableRLS() -export const profiles = pgTable( - "profiles", +// === certs === +export const certs = pgTable("certs", { + id: serial("id").primaryKey().notNull(), + name: varchar("name", { length: 100 }), + link: text("link") +}).enableRLS() + +// === places === +export const places = pgTable( + "places", { - id: uuid("id").notNull().primaryKey(), - firstName: text("first_name"), - lastName: text("last_name") + id: serial("id").primaryKey().notNull(), + coord_x: decimal("coord_x"), + coord_y: decimal("coord_y"), + description: varchar("description", { length: 255 }), + name: varchar("name", { length: 100 }), + id_user: uuid("id_user") + .notNull() + .references(() => authUsers.id, { onDelete: "cascade" }), + hidden_place: boolean("hidden_place") }, (table) => [ - foreignKey({ - columns: [table.id], - foreignColumns: [authUsers.id], - name: "profiles_id_fkey" - }).onDelete("cascade"), - pgPolicy("select-own-profile", { + pgPolicy("select-own-places", { for: "select", to: authenticatedRole, - using: sql`${table.id} = auth.uid()` + using: sql`${table.id_user} = auth.uid()` }), - pgPolicy("update-own-profile", { - for: "update", - to: authenticatedRole, - using: sql`${table.id} = auth.uid()`, - withCheck: sql`${table.id} = auth.uid()` - }), - pgPolicy("insert-profile", { + pgPolicy("insert-own-places", { for: "insert", to: authenticatedRole, - withCheck: sql`${table.id} = auth.uid()` - }) - ] -).enableRLS() - -// === Catálogo de certificaciones === -export const certifications = pgTable( - "certifications", - { - id: serial("id").primaryKey(), - name: text("name").notNull() - }, - () => [ - // Política: todos los usuarios autenticados pueden leer, nadie puede escribir - pgPolicy("select-certifications", { - for: "select", + withCheck: sql`${table.id_user} = auth.uid()` + }), + pgPolicy("update-own-places", { + for: "update", to: authenticatedRole, - using: sql`true` + using: sql`${table.id_user} = auth.uid()`, + withCheck: sql`${table.id_user} = auth.uid()` }) ] ).enableRLS() -// === Catálogo de modelos de drones === -export const droneModels = pgTable( - "drone_models", +// === users_drones === +export const usersDrones = pgTable( + "users_drones", { - id: serial("id").primaryKey(), - name: text("name").notNull() - }, - () => [ - pgPolicy("select-drone-models", { - for: "select", - to: authenticatedRole, - using: sql`true` - }) - ] -).enableRLS() - -// === Tabla principal de pilotos === -export const pilots = pgTable( - "pilots", - { - id: uuid("id").notNull().primaryKey(), // Igual que auth.uid() - name: text("name"), - location: text("location"), - latitude: doublePrecision("latitude"), - longitude: doublePrecision("longitude"), - company: text("company"), - position: text("position"), - description: text("description"), - differentiation: text("differentiation"), - coverageAreas: text("coverage_areas"), - specializationAreas: text("specialization_areas"), - certificationIds: integer("certification_ids").array(), // IDs de tabla certifications - droneModelIds: integer("drone_model_ids").array(), // IDs de tabla drone_models - email: text("email") + id: serial("id").primaryKey().notNull(), + id_drone: integer("id_drone").references(() => drones.id), + id_user: uuid("id_user").references(() => authUsers.id) }, (table) => [ - // Relación con la tabla auth.users - foreignKey({ - columns: [table.id], - foreignColumns: [authUsers.id], - name: "pilots_id_fkey" - }).onDelete("cascade"), - - // === RLS === - pgPolicy("select-own-pilot", { + pgPolicy("select-own-user-drones", { for: "select", to: authenticatedRole, - using: sql`${table.id} = auth.uid()` + using: sql`${table.id_user} = auth.uid()` }), - pgPolicy("update-own-pilot", { - for: "update", - to: authenticatedRole, - using: sql`${table.id} = auth.uid()`, - withCheck: sql`${table.id} = auth.uid()` - }), - pgPolicy("insert-pilot", { + pgPolicy("insert-own-user-drones", { for: "insert", to: authenticatedRole, - withCheck: sql`${table.id} = auth.uid()` + withCheck: sql`${table.id_user} = auth.uid()` }) ] ).enableRLS() + +// === users_certs === +export const usersCerts = pgTable( + "users_certs", + { + id: serial("id").primaryKey().notNull(), + id_cert: integer("id_cert").references(() => certs.id), + id_user: uuid("id_user").references(() => authUsers.id) + }, + (table) => [ + pgPolicy("select-own-user-certs", { + for: "select", + to: authenticatedRole, + using: sql`${table.id_user} = auth.uid()` + }), + pgPolicy("insert-own-user-certs", { + for: "insert", + to: authenticatedRole, + withCheck: sql`${table.id_user} = auth.uid()` + }) + ] +).enableRLS() + +// === users_places === +export const usersPlaces = pgTable( + "users_places", + { + id: serial("id").primaryKey().notNull(), + id_place: integer("id_place").references(() => places.id), + id_user: uuid("id_user").references(() => authUsers.id) + }, + (table) => [ + pgPolicy("select-own-user-places", { + for: "select", + to: authenticatedRole, + using: sql`${table.id_user} = auth.uid()` + }), + pgPolicy("insert-own-user-places", { + for: "insert", + to: authenticatedRole, + withCheck: sql`${table.id_user} = auth.uid()` + }) + ] +).enableRLS() + +// === equipment === +export const equipment = pgTable("equipment", { + id: serial("id").primaryKey().notNull() +}).enableRLS() diff --git a/src/integrations/supabase/migrations/0000_talented_doorman.sql b/src/integrations/supabase/migrations/0000_talented_doorman.sql deleted file mode 100644 index 36609bf..0000000 --- a/src/integrations/supabase/migrations/0000_talented_doorman.sql +++ /dev/null @@ -1,5 +0,0 @@ -IF NOT EXISTS CREATE TABLE "demo" ( - "id" serial PRIMARY KEY NOT NULL, - "full_name" text, - "phone" varchar(256) -); diff --git a/src/integrations/supabase/migrations/0001_nice_gargoyle.sql b/src/integrations/supabase/migrations/0001_nice_gargoyle.sql deleted file mode 100644 index df3af4b..0000000 --- a/src/integrations/supabase/migrations/0001_nice_gargoyle.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "profiles" ( - "id" uuid PRIMARY KEY NOT NULL, - "first_name" text, - "last_name" text -); ---> statement-breakpoint -ALTER TABLE "profiles" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint -ALTER TABLE "profiles" ADD CONSTRAINT "profiles_id_fkey" FOREIGN KEY ("id") REFERENCES "auth"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE POLICY "select-own-profile" ON "profiles" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("profiles"."id" = auth.uid());--> statement-breakpoint -CREATE POLICY "update-own-profile" ON "profiles" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ("profiles"."id" = auth.uid()) WITH CHECK ("profiles"."id" = auth.uid());--> statement-breakpoint -CREATE POLICY "insert-profile" ON "profiles" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("profiles"."id" = auth.uid()); \ No newline at end of file diff --git a/src/integrations/supabase/migrations/0002_bouncy_apocalypse.sql b/src/integrations/supabase/migrations/0002_bouncy_apocalypse.sql deleted file mode 100644 index eb17788..0000000 --- a/src/integrations/supabase/migrations/0002_bouncy_apocalypse.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE "certifications" ( - "id" serial PRIMARY KEY NOT NULL, - "name" text NOT NULL -); ---> statement-breakpoint -ALTER TABLE "certifications" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint -CREATE TABLE "drone_models" ( - "id" serial PRIMARY KEY NOT NULL, - "name" text NOT NULL -); ---> statement-breakpoint -ALTER TABLE "drone_models" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint -CREATE TABLE "pilots" ( - "id" uuid PRIMARY KEY NOT NULL, - "name" text, - "location" text, - "latitude" double precision, - "longitude" double precision, - "company" text, - "position" text, - "description" text, - "differentiation" text, - "coverage_areas" text, - "specialization_areas" text, - "certification_ids" integer[], - "drone_model_ids" integer[], - "email" text -); ---> statement-breakpoint -ALTER TABLE "pilots" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint -ALTER TABLE "pilots" ADD CONSTRAINT "pilots_id_fkey" FOREIGN KEY ("id") REFERENCES "auth"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE POLICY "select-certifications" ON "certifications" AS PERMISSIVE FOR SELECT TO "authenticated" USING (true);--> statement-breakpoint -CREATE POLICY "select-drone-models" ON "drone_models" AS PERMISSIVE FOR SELECT TO "authenticated" USING (true);--> statement-breakpoint -CREATE POLICY "select-own-pilot" ON "pilots" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("pilots"."id" = auth.uid());--> statement-breakpoint -CREATE POLICY "update-own-pilot" ON "pilots" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ("pilots"."id" = auth.uid()) WITH CHECK ("pilots"."id" = auth.uid());--> statement-breakpoint -CREATE POLICY "insert-pilot" ON "pilots" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("pilots"."id" = auth.uid()); \ No newline at end of file diff --git a/src/integrations/supabase/migrations/0002_init.sql b/src/integrations/supabase/migrations/0002_init.sql new file mode 100644 index 0000000..11c566c --- /dev/null +++ b/src/integrations/supabase/migrations/0002_init.sql @@ -0,0 +1,68 @@ +CREATE TABLE "certs" ( + "id" serial PRIMARY KEY NOT NULL, + "name" varchar(100), + "link" text +); +--> statement-breakpoint +ALTER TABLE "certs" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "drones" ( + "id" serial PRIMARY KEY NOT NULL, + "model" varchar(100), + "brand" varchar(100), + "type" jsonb +); +--> statement-breakpoint +ALTER TABLE "drones" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "equipment" ( + "id" serial PRIMARY KEY NOT NULL +); +--> statement-breakpoint +ALTER TABLE "equipment" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "places" ( + "id" serial PRIMARY KEY NOT NULL, + "coord_x" numeric, + "coord_y" numeric, + "description" varchar(255), + "name" varchar(100), + "id_user" uuid NOT NULL, + "hidden_place" boolean +); +--> statement-breakpoint +ALTER TABLE "places" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "users_certs" ( + "id" serial PRIMARY KEY NOT NULL, + "id_cert" integer, + "id_user" uuid +); +--> statement-breakpoint +ALTER TABLE "users_certs" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "users_drones" ( + "id" serial PRIMARY KEY NOT NULL, + "id_drone" integer, + "id_user" uuid +); +--> statement-breakpoint +ALTER TABLE "users_drones" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "users_places" ( + "id" serial PRIMARY KEY NOT NULL, + "id_place" integer, + "id_user" uuid +); +--> statement-breakpoint +ALTER TABLE "users_places" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +ALTER TABLE "places" ADD CONSTRAINT "places_id_user_users_id_fk" FOREIGN KEY ("id_user") REFERENCES "auth"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "users_certs" ADD CONSTRAINT "users_certs_id_cert_certs_id_fk" FOREIGN KEY ("id_cert") REFERENCES "public"."certs"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "users_certs" ADD CONSTRAINT "users_certs_id_user_users_id_fk" FOREIGN KEY ("id_user") REFERENCES "auth"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "users_drones" ADD CONSTRAINT "users_drones_id_drone_drones_id_fk" FOREIGN KEY ("id_drone") REFERENCES "public"."drones"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "users_drones" ADD CONSTRAINT "users_drones_id_user_users_id_fk" FOREIGN KEY ("id_user") REFERENCES "auth"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "users_places" ADD CONSTRAINT "users_places_id_place_places_id_fk" FOREIGN KEY ("id_place") REFERENCES "public"."places"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "users_places" ADD CONSTRAINT "users_places_id_user_users_id_fk" FOREIGN KEY ("id_user") REFERENCES "auth"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE POLICY "select-own-places" ON "places" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("places"."id_user" = auth.uid());--> statement-breakpoint +CREATE POLICY "insert-own-places" ON "places" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("places"."id_user" = auth.uid());--> statement-breakpoint +CREATE POLICY "update-own-places" ON "places" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ("places"."id_user" = auth.uid()) WITH CHECK ("places"."id_user" = auth.uid());--> statement-breakpoint +CREATE POLICY "select-own-user-certs" ON "users_certs" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("users_certs"."id_user" = auth.uid());--> statement-breakpoint +CREATE POLICY "insert-own-user-certs" ON "users_certs" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("users_certs"."id_user" = auth.uid());--> statement-breakpoint +CREATE POLICY "select-own-user-drones" ON "users_drones" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("users_drones"."id_user" = auth.uid());--> statement-breakpoint +CREATE POLICY "insert-own-user-drones" ON "users_drones" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("users_drones"."id_user" = auth.uid());--> statement-breakpoint +CREATE POLICY "select-own-user-places" ON "users_places" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("users_places"."id_user" = auth.uid());--> statement-breakpoint +CREATE POLICY "insert-own-user-places" ON "users_places" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("users_places"."id_user" = auth.uid()); \ No newline at end of file diff --git a/src/integrations/supabase/migrations/meta/0000_snapshot.json b/src/integrations/supabase/migrations/meta/0000_snapshot.json deleted file mode 100644 index 28c2c94..0000000 --- a/src/integrations/supabase/migrations/meta/0000_snapshot.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "id": "c266fe94-b863-4b6c-930c-44af8af68c1a", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.demo": { - "name": "demo", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/src/integrations/supabase/migrations/meta/0001_snapshot.json b/src/integrations/supabase/migrations/meta/0001_snapshot.json deleted file mode 100644 index c313063..0000000 --- a/src/integrations/supabase/migrations/meta/0001_snapshot.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "id": "7d0d4272-65ba-45cf-9dd3-a5e2008d3744", - "prevId": "c266fe94-b863-4b6c-930c-44af8af68c1a", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.profiles": { - "name": "profiles", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "profiles_id_fkey": { - "name": "profiles_id_fkey", - "tableFrom": "profiles", - "tableTo": "users", - "schemaTo": "auth", - "columnsFrom": [ - "id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": { - "select-own-profile": { - "name": "select-own-profile", - "as": "PERMISSIVE", - "for": "SELECT", - "to": [ - "authenticated" - ], - "using": "\"profiles\".\"id\" = auth.uid()" - }, - "update-own-profile": { - "name": "update-own-profile", - "as": "PERMISSIVE", - "for": "UPDATE", - "to": [ - "authenticated" - ], - "using": "\"profiles\".\"id\" = auth.uid()", - "withCheck": "\"profiles\".\"id\" = auth.uid()" - }, - "insert-profile": { - "name": "insert-profile", - "as": "PERMISSIVE", - "for": "INSERT", - "to": [ - "authenticated" - ], - "withCheck": "\"profiles\".\"id\" = auth.uid()" - } - }, - "checkConstraints": {}, - "isRLSEnabled": true - }, - "public.demo": { - "name": "demo", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/src/integrations/supabase/migrations/meta/0002_snapshot.json b/src/integrations/supabase/migrations/meta/0002_snapshot.json index 0bf34bf..ed07e77 100644 --- a/src/integrations/supabase/migrations/meta/0002_snapshot.json +++ b/src/integrations/supabase/migrations/meta/0002_snapshot.json @@ -1,11 +1,11 @@ { - "id": "462e99b2-ba6b-4c91-9f6b-891795695955", - "prevId": "7d0d4272-65ba-45cf-9dd3-a5e2008d3744", + "id": "595b3231-9696-413e-b55b-5ec61cb86165", + "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", "tables": { - "public.certifications": { - "name": "certifications", + "public.certs": { + "name": "certs", "schema": "", "columns": { "id": { @@ -16,300 +16,14 @@ }, "name": { "name": "name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", "type": "text", "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": { - "select-certifications": { - "name": "select-certifications", - "as": "PERMISSIVE", - "for": "SELECT", - "to": [ - "authenticated" - ], - "using": "true" - } - }, - "checkConstraints": {}, - "isRLSEnabled": true - }, - "public.drone_models": { - "name": "drone_models", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": { - "select-drone-models": { - "name": "select-drone-models", - "as": "PERMISSIVE", - "for": "SELECT", - "to": [ - "authenticated" - ], - "using": "true" - } - }, - "checkConstraints": {}, - "isRLSEnabled": true - }, - "public.pilots": { - "name": "pilots", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "location": { - "name": "location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "latitude": { - "name": "latitude", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "longitude": { - "name": "longitude", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "company": { - "name": "company", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "position": { - "name": "position", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "differentiation": { - "name": "differentiation", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "coverage_areas": { - "name": "coverage_areas", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "specialization_areas": { - "name": "specialization_areas", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "certification_ids": { - "name": "certification_ids", - "type": "integer[]", - "primaryKey": false, - "notNull": false - }, - "drone_model_ids": { - "name": "drone_model_ids", - "type": "integer[]", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pilots_id_fkey": { - "name": "pilots_id_fkey", - "tableFrom": "pilots", - "tableTo": "users", - "schemaTo": "auth", - "columnsFrom": [ - "id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": { - "select-own-pilot": { - "name": "select-own-pilot", - "as": "PERMISSIVE", - "for": "SELECT", - "to": [ - "authenticated" - ], - "using": "\"pilots\".\"id\" = auth.uid()" - }, - "update-own-pilot": { - "name": "update-own-pilot", - "as": "PERMISSIVE", - "for": "UPDATE", - "to": [ - "authenticated" - ], - "using": "\"pilots\".\"id\" = auth.uid()", - "withCheck": "\"pilots\".\"id\" = auth.uid()" - }, - "insert-pilot": { - "name": "insert-pilot", - "as": "PERMISSIVE", - "for": "INSERT", - "to": [ - "authenticated" - ], - "withCheck": "\"pilots\".\"id\" = auth.uid()" - } - }, - "checkConstraints": {}, - "isRLSEnabled": true - }, - "public.profiles": { - "name": "profiles", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "profiles_id_fkey": { - "name": "profiles_id_fkey", - "tableFrom": "profiles", - "tableTo": "users", - "schemaTo": "auth", - "columnsFrom": [ - "id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": { - "select-own-profile": { - "name": "select-own-profile", - "as": "PERMISSIVE", - "for": "SELECT", - "to": [ - "authenticated" - ], - "using": "\"profiles\".\"id\" = auth.uid()" - }, - "update-own-profile": { - "name": "update-own-profile", - "as": "PERMISSIVE", - "for": "UPDATE", - "to": [ - "authenticated" - ], - "using": "\"profiles\".\"id\" = auth.uid()", - "withCheck": "\"profiles\".\"id\" = auth.uid()" - }, - "insert-profile": { - "name": "insert-profile", - "as": "PERMISSIVE", - "for": "INSERT", - "to": [ - "authenticated" - ], - "withCheck": "\"profiles\".\"id\" = auth.uid()" - } - }, - "checkConstraints": {}, - "isRLSEnabled": true - }, - "public.demo": { - "name": "demo", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "varchar(256)", - "primaryKey": false, "notNull": false } }, @@ -319,7 +33,396 @@ "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, - "isRLSEnabled": false + "isRLSEnabled": true + }, + "public.drones": { + "name": "drones", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "model": { + "name": "model", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "brand": { + "name": "brand", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.equipment": { + "name": "equipment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.places": { + "name": "places", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "coord_x": { + "name": "coord_x", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "coord_y": { + "name": "coord_y", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "id_user": { + "name": "id_user", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "hidden_place": { + "name": "hidden_place", + "type": "boolean", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "places_id_user_users_id_fk": { + "name": "places_id_user_users_id_fk", + "tableFrom": "places", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "id_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": { + "select-own-places": { + "name": "select-own-places", + "as": "PERMISSIVE", + "for": "SELECT", + "to": [ + "authenticated" + ], + "using": "\"places\".\"id_user\" = auth.uid()" + }, + "insert-own-places": { + "name": "insert-own-places", + "as": "PERMISSIVE", + "for": "INSERT", + "to": [ + "authenticated" + ], + "withCheck": "\"places\".\"id_user\" = auth.uid()" + }, + "update-own-places": { + "name": "update-own-places", + "as": "PERMISSIVE", + "for": "UPDATE", + "to": [ + "authenticated" + ], + "using": "\"places\".\"id_user\" = auth.uid()", + "withCheck": "\"places\".\"id_user\" = auth.uid()" + } + }, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.users_certs": { + "name": "users_certs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "id_cert": { + "name": "id_cert", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "id_user": { + "name": "id_user", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "users_certs_id_cert_certs_id_fk": { + "name": "users_certs_id_cert_certs_id_fk", + "tableFrom": "users_certs", + "tableTo": "certs", + "columnsFrom": [ + "id_cert" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "users_certs_id_user_users_id_fk": { + "name": "users_certs_id_user_users_id_fk", + "tableFrom": "users_certs", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "id_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": { + "select-own-user-certs": { + "name": "select-own-user-certs", + "as": "PERMISSIVE", + "for": "SELECT", + "to": [ + "authenticated" + ], + "using": "\"users_certs\".\"id_user\" = auth.uid()" + }, + "insert-own-user-certs": { + "name": "insert-own-user-certs", + "as": "PERMISSIVE", + "for": "INSERT", + "to": [ + "authenticated" + ], + "withCheck": "\"users_certs\".\"id_user\" = auth.uid()" + } + }, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.users_drones": { + "name": "users_drones", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "id_drone": { + "name": "id_drone", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "id_user": { + "name": "id_user", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "users_drones_id_drone_drones_id_fk": { + "name": "users_drones_id_drone_drones_id_fk", + "tableFrom": "users_drones", + "tableTo": "drones", + "columnsFrom": [ + "id_drone" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "users_drones_id_user_users_id_fk": { + "name": "users_drones_id_user_users_id_fk", + "tableFrom": "users_drones", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "id_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": { + "select-own-user-drones": { + "name": "select-own-user-drones", + "as": "PERMISSIVE", + "for": "SELECT", + "to": [ + "authenticated" + ], + "using": "\"users_drones\".\"id_user\" = auth.uid()" + }, + "insert-own-user-drones": { + "name": "insert-own-user-drones", + "as": "PERMISSIVE", + "for": "INSERT", + "to": [ + "authenticated" + ], + "withCheck": "\"users_drones\".\"id_user\" = auth.uid()" + } + }, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.users_places": { + "name": "users_places", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "id_place": { + "name": "id_place", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "id_user": { + "name": "id_user", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "users_places_id_place_places_id_fk": { + "name": "users_places_id_place_places_id_fk", + "tableFrom": "users_places", + "tableTo": "places", + "columnsFrom": [ + "id_place" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "users_places_id_user_users_id_fk": { + "name": "users_places_id_user_users_id_fk", + "tableFrom": "users_places", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "id_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": { + "select-own-user-places": { + "name": "select-own-user-places", + "as": "PERMISSIVE", + "for": "SELECT", + "to": [ + "authenticated" + ], + "using": "\"users_places\".\"id_user\" = auth.uid()" + }, + "insert-own-user-places": { + "name": "insert-own-user-places", + "as": "PERMISSIVE", + "for": "INSERT", + "to": [ + "authenticated" + ], + "withCheck": "\"users_places\".\"id_user\" = auth.uid()" + } + }, + "checkConstraints": {}, + "isRLSEnabled": true } }, "enums": {}, diff --git a/src/integrations/supabase/migrations/meta/_journal.json b/src/integrations/supabase/migrations/meta/_journal.json index 831c324..35f1686 100644 --- a/src/integrations/supabase/migrations/meta/_journal.json +++ b/src/integrations/supabase/migrations/meta/_journal.json @@ -1,27 +1,13 @@ { - "version": "7", - "dialect": "postgresql", - "entries": [ - { - "idx": 0, - "version": "7", - "when": 1754932713212, - "tag": "0000_talented_doorman", - "breakpoints": true - }, - { - "idx": 1, - "version": "7", - "when": 1755013739316, - "tag": "0001_nice_gargoyle", - "breakpoints": true - }, - { - "idx": 2, - "version": "7", - "when": 1755075449620, - "tag": "0002_bouncy_apocalypse", - "breakpoints": true - } - ] -} \ No newline at end of file + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 2, + "version": "7", + "when": 1762798763195, + "tag": "0002_init", + "breakpoints": true + } + ] +}