diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 639c118..1e588c7 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -4,22 +4,40 @@ on:
push:
branches: ["main"]
env:
- IMAGE_NAME: "djsisson/portfolio"
+ IMAGE_NAME: "portfolio"
jobs:
- amd64:
+ setup-warp:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Setup Cloudflare WARP Connector
+ uses: wallravit/cloudflare-warp-connector@v1.0.0
+ with:
+ organization: ${{ secrets.CLOUDFLARE_ORGANIZATION_ID }}
+ cloudflare_access_client_id: ${{ secrets.CF_ID }}
+ cloudflare_client_secret: ${{ secrets.CF_SECRET }}
+ cloudflare_warp_token: ${{ secrets.CLOUDFLARE_WARP_TOKEN }}
+
+ - name: Check WARP Registration
+ run: warp-cli --accept-tos registration show
+
+ - name: Check WARP Status
+ run: warp-cli --accept-tos status
+ build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- - uses: actions/checkout@v4
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
- name: Build image and push to registry
uses: docker/build-push-action@v6
with:
@@ -27,7 +45,6 @@ jobs:
file: Dockerfile
platforms: linux/amd64
push: true
- tags: ${{ secrets.REGISTRY_URL }}/${{ env.IMAGE_NAME }}:latest
- - name: Deploy to Coolify
- run: |
- curl --request GET '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}' --header 'CF-Access-Client-Id: ${{ secrets.CF_ID }}' --header 'CF-Access-Client-Secret: ${{ secrets.CF_SECRET }}'
+ tags: |
+ ${{ secrets.REGISTRY_URL }}/${{ env.IMAGE_NAME }}:latest
+ ${{ secrets.REGISTRY_URL }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
diff --git a/.gitignore b/.gitignore
index 91235c7..486786d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,8 +27,8 @@ yarn-error.log*
# local env files
.env*.local
+.env*.production
.env
-
# vercel
.vercel
@@ -36,4 +36,5 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts
docker-compose-dev.yaml
+compose.yaml
Dockerfile.dev
\ No newline at end of file
diff --git a/package.json b/package.json
index ab0b44e..2e31713 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,8 @@
"driz-gen": "yarn drizzle-kit generate",
"driz-mig": "yarn drizzle-kit migrate",
"seed": "yarn dlx tsx ./src/db/seed/seed.ts",
- "blur": "yarn dlx tsx ./processImages.ts"
+ "blur": "yarn dlx tsx ./processImages.ts",
+ "test-build": "docker buildx build -t 10.0.0.2:5000/portfolio:latest --push ."
},
"dependencies": {
"@mdx-js/loader": "^3.1.0",
diff --git a/src/app/genshin/components/Char-Info.tsx b/src/app/genshin/components/Char-Info.tsx
index 077cb1e..c96e484 100755
--- a/src/app/genshin/components/Char-Info.tsx
+++ b/src/app/genshin/components/Char-Info.tsx
@@ -20,7 +20,7 @@ export default function CharInfo({ character }: { character: Characters[0] }) {
src={value}
alt={key}
fill={true}
- priority={false}
+ priority={true}
/>
);
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index c8672d0..e483439 100755
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { ThemeProvider } from "next-themes";
import { Inter } from "next/font/google";
import "./global.css";
+import { headers } from "next/headers";
export const metadata: Metadata = {
title: "Portfolio",
@@ -13,15 +14,16 @@ const inter = Inter({
variable: "--font-inter",
});
-export default function RootLayout({
+export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
+ const nonce = (await headers()).get("x-nonce");
return (
-
+
{children}
diff --git a/src/app/todos/actions.ts b/src/app/todos/actions.ts
index 9d40849..ecf9496 100644
--- a/src/app/todos/actions.ts
+++ b/src/app/todos/actions.ts
@@ -56,6 +56,7 @@ export async function listTodos() {
if (!jwt) {
return [] as (typeof todos.$inferSelect)[];
}
+
const result = await dbClient(jwt as JWTPayload).rls(async (tx) => {
const todoList = await tx
.select()
diff --git a/src/db/db.ts b/src/db/db.ts
index 62d44a1..aef3a5b 100755
--- a/src/db/db.ts
+++ b/src/db/db.ts
@@ -7,7 +7,7 @@ import * as asteroidz_relations from "./asteroidz/relations";
import * as forum_schema from "./forum/schema";
import { loadEnvConfig } from "@next/env";
-loadEnvConfig(process.cwd(), true);
+loadEnvConfig(process.cwd(), false);
// import * as forum_relations from "./forum/relations";
const connectionString = process.env.DATABASE_URL!;
diff --git a/src/db/forum/db.ts b/src/db/forum/db.ts
index f984740..13fef0d 100644
--- a/src/db/forum/db.ts
+++ b/src/db/forum/db.ts
@@ -42,7 +42,7 @@ export function dbClient(
token.sub ?? "",
)}', TRUE);
-- set local role
- set local role ${sql.raw(token.role ?? "anon")};
+ set local role ${sql.raw(token.aud?.toString() ?? "anon")};
`);
return await transaction(tx);
} finally {
diff --git a/src/db/forum/schema.ts b/src/db/forum/schema.ts
index 1d4bfdc..393b265 100644
--- a/src/db/forum/schema.ts
+++ b/src/db/forum/schema.ts
@@ -148,13 +148,13 @@ export const likes = pgTable(
as: "permissive",
for: "delete",
to: authenticatedRole,
- using: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT uid() AS uid))))`,
+ using: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))`,
}),
pgPolicy("likes_insert_policy", {
as: "permissive",
for: "insert",
to: authenticatedRole,
- withCheck: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT uid() AS uid))))`,
+ withCheck: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))`,
}),
pgPolicy("likes_select_policy", {
as: "permissive",
@@ -166,8 +166,8 @@ export const likes = pgTable(
as: "permissive",
for: "update",
to: authenticatedRole,
- withCheck: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT uid() AS uid))))`,
- using: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT uid() AS uid))))`,
+ withCheck: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))`,
+ using: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))`,
}),
],
);
@@ -283,13 +283,13 @@ export const user_follows = pgTable(
as: "permissive",
for: "delete",
to: authenticatedRole,
- using: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT uid() AS uid))))`,
+ using: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))`,
}),
pgPolicy("user_follows_insert_policy", {
as: "permissive",
for: "insert",
to: authenticatedRole,
- withCheck: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT uid() AS uid))))`,
+ withCheck: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))`,
}),
pgPolicy("user_follows_select_policy", {
as: "permissive",
@@ -301,8 +301,8 @@ export const user_follows = pgTable(
as: "permissive",
for: "update",
to: authenticatedRole,
- using: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT uid() AS uid))))`,
- withCheck: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT uid() AS uid))))`,
+ using: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))`,
+ withCheck: sql`(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))`,
}),
],
);
diff --git a/src/db/genshin/schema.ts b/src/db/genshin/schema.ts
index 0910aa7..308fba2 100644
--- a/src/db/genshin/schema.ts
+++ b/src/db/genshin/schema.ts
@@ -1,4 +1,4 @@
-import { pgTable, integer, text, unique } from "drizzle-orm/pg-core";
+import { pgTable, integer, text, unique, index } from "drizzle-orm/pg-core";
export const elements = pgTable(
"elements",
@@ -42,8 +42,11 @@ export const characters = pgTable(
},
(table) => [
unique("characters_name_unique").on(table.name),
- unique("characters_city_id_cities_id_fk").on(table.city_id),
- unique("characters_element_id_elements_id_fk").on(table.element_id),
+ index("characters_city_id_cities_id_fk").using("btree", table.city_id),
+ index("characters_element_id_elements_id_fk").using(
+ "btree",
+ table.element_id,
+ ),
],
);
diff --git a/src/db/migrations/20241030170954_petite_whistler.sql b/src/db/migrations/20250117221840_crazy_spitfire.sql
similarity index 81%
rename from src/db/migrations/20241030170954_petite_whistler.sql
rename to src/db/migrations/20250117221840_crazy_spitfire.sql
index 7187391..bc75fea 100644
--- a/src/db/migrations/20241030170954_petite_whistler.sql
+++ b/src/db/migrations/20250117221840_crazy_spitfire.sql
@@ -1,29 +1,3 @@
--- Current sql file was generated after introspecting the database
--- If you want to run this migration please uncomment this code before executing migrations
-/*
-CREATE TABLE IF NOT EXISTS "characters" (
- "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "characters_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
- "name" text NOT NULL,
- "description" text[] NOT NULL,
- "element_id" integer NOT NULL,
- "city_id" integer NOT NULL,
- CONSTRAINT "characters_name_unique" UNIQUE("name")
-);
---> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "cities" (
- "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "cities_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
- "name" text NOT NULL,
- CONSTRAINT "cities_name_unique" UNIQUE("name")
-);
---> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "elements" (
- "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "elements_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
- "name" text NOT NULL,
- "colour" text NOT NULL,
- CONSTRAINT "elements_name_unique" UNIQUE("name"),
- CONSTRAINT "elements_colour_unique" UNIQUE("colour")
-);
---> statement-breakpoint
CREATE TABLE IF NOT EXISTS "gamestate" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "gamestats_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"playername" text NOT NULL,
@@ -38,12 +12,21 @@ CREATE TABLE IF NOT EXISTS "gamestate" (
"items" json[] NOT NULL
);
--> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "hashtags" (
- "id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
- "hashtag" text NOT NULL
+CREATE TABLE IF NOT EXISTS "items_required_items" (
+ "item_id" integer NOT NULL,
+ "required_id" integer NOT NULL,
+ "quantity" integer NOT NULL,
+ "description" text NOT NULL,
+ CONSTRAINT "items_required_items_item_id_required_id_pk" PRIMARY KEY("item_id","required_id")
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "items_required_research" (
+ "item_id" integer NOT NULL,
+ "required_id" integer NOT NULL,
+ "description" text NOT NULL,
+ CONSTRAINT "items_required_research_item_id_required_id_pk" PRIMARY KEY("item_id","required_id")
);
--> statement-breakpoint
-ALTER TABLE "hashtags" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "levels" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "levels_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"level" integer NOT NULL,
@@ -54,16 +37,6 @@ CREATE TABLE IF NOT EXISTS "levels" (
"critDamage" real NOT NULL
);
--> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "messages" (
- "id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
- "user_id" uuid NOT NULL,
- "parent_id" uuid,
- "message" text NOT NULL,
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
- "updated_at" timestamp with time zone
-);
---> statement-breakpoint
-ALTER TABLE "messages" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "research" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "research_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"name" text NOT NULL,
@@ -71,6 +44,21 @@ CREATE TABLE IF NOT EXISTS "research" (
"cost" integer NOT NULL
);
--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "research_required_items" (
+ "research_id" integer NOT NULL,
+ "item_id" integer NOT NULL,
+ "quantity" integer NOT NULL,
+ "description" text NOT NULL,
+ CONSTRAINT "research_required_items_research_id_item_id_pk" PRIMARY KEY("research_id","item_id")
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "research_required_research" (
+ "research_id" integer NOT NULL,
+ "required_id" integer NOT NULL,
+ "description" text NOT NULL,
+ CONSTRAINT "research_required_research_research_id_required_id_pk" PRIMARY KEY("research_id","required_id")
+);
+--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "shop_items" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "shop_items_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"name" text NOT NULL,
@@ -82,6 +70,60 @@ CREATE TABLE IF NOT EXISTS "shop_items" (
"critDamage" real NOT NULL
);
--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "upgrade_required_items" (
+ "upgrade_id" integer NOT NULL,
+ "item_id" integer NOT NULL,
+ "quantity" integer NOT NULL,
+ "description" text NOT NULL,
+ CONSTRAINT "upgrade_required_items_upgrade_id_item_id_pk" PRIMARY KEY("upgrade_id","item_id")
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "upgrade_required_research" (
+ "upgrade_id" integer NOT NULL,
+ "required_id" integer NOT NULL,
+ "description" text NOT NULL,
+ CONSTRAINT "upgrade_required_research_upgrade_id_research_id_pk" PRIMARY KEY("upgrade_id","required_id")
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "upgrades" (
+ "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "upgrades_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
+ "name" text NOT NULL,
+ "description" text NOT NULL,
+ "effectItemId" integer NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "characters" (
+ "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "characters_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
+ "name" text NOT NULL,
+ "description" text[] NOT NULL,
+ "element_id" integer NOT NULL,
+ "city_id" integer NOT NULL,
+ CONSTRAINT "characters_name_unique" UNIQUE("name")
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "cities" (
+ "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "cities_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
+ "name" text NOT NULL,
+ CONSTRAINT "cities_name_unique" UNIQUE("name")
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "elements" (
+ "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "elements_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
+ "name" text NOT NULL,
+ "colour" text NOT NULL,
+ CONSTRAINT "elements_name_unique" UNIQUE("name"),
+ CONSTRAINT "elements_colour_unique" UNIQUE("colour")
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "todos" (
+ "id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
+ "title" text NOT NULL,
+ "completed" boolean DEFAULT false NOT NULL,
+ "user_id" uuid NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+ALTER TABLE "todos" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "tilez_games" (
"id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
"game_id" text NOT NULL,
@@ -101,34 +143,6 @@ CREATE TABLE IF NOT EXISTS "tilez_words" (
);
--> statement-breakpoint
ALTER TABLE "tilez_words" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "todos" (
- "id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
- "title" text NOT NULL,
- "completed" boolean DEFAULT false NOT NULL,
- "user_id" uuid NOT NULL,
- "created_at" timestamp with time zone DEFAULT now() NOT NULL
-);
---> statement-breakpoint
-ALTER TABLE "todos" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "upgrades" (
- "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "upgrades_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
- "name" text NOT NULL,
- "description" text NOT NULL,
- "effectItemId" integer NOT NULL
-);
---> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "users" (
- "id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
- "user_id" uuid,
- "username" text NOT NULL,
- "email" text NOT NULL,
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
- "updated_at" timestamp with time zone,
- "bio" text,
- "avatar" text
-);
---> statement-breakpoint
-ALTER TABLE "users" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "hashtag_messages" (
"hashtag_id" uuid NOT NULL,
"message_id" uuid NOT NULL,
@@ -136,20 +150,12 @@ CREATE TABLE IF NOT EXISTS "hashtag_messages" (
);
--> statement-breakpoint
ALTER TABLE "hashtag_messages" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "user_follows" (
- "user_id" uuid NOT NULL,
- "following_user_id" uuid NOT NULL,
- CONSTRAINT "user_follows_pk" PRIMARY KEY("user_id","following_user_id")
-);
---> statement-breakpoint
-ALTER TABLE "user_follows" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "items_required_research" (
- "item_id" integer NOT NULL,
- "required_id" integer NOT NULL,
- "description" text NOT NULL,
- CONSTRAINT "items_required_research_item_id_required_id_pk" PRIMARY KEY("item_id","required_id")
+CREATE TABLE IF NOT EXISTS "hashtags" (
+ "id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
+ "hashtag" text NOT NULL
);
--> statement-breakpoint
+ALTER TABLE "hashtags" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "likes" (
"user_id" uuid NOT NULL,
"message_id" uuid NOT NULL,
@@ -158,256 +164,246 @@ CREATE TABLE IF NOT EXISTS "likes" (
);
--> statement-breakpoint
ALTER TABLE "likes" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "research_required_research" (
- "research_id" integer NOT NULL,
- "required_id" integer NOT NULL,
- "description" text NOT NULL,
- CONSTRAINT "research_required_research_research_id_required_id_pk" PRIMARY KEY("research_id","required_id")
-);
---> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "upgrade_required_research" (
- "upgrade_id" integer NOT NULL,
- "required_id" integer NOT NULL,
- "description" text NOT NULL,
- CONSTRAINT "upgrade_required_research_upgrade_id_research_id_pk" PRIMARY KEY("upgrade_id","required_id")
-);
---> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "items_required_items" (
- "item_id" integer NOT NULL,
- "required_id" integer NOT NULL,
- "quantity" integer NOT NULL,
- "description" text NOT NULL,
- CONSTRAINT "items_required_items_item_id_required_id_pk" PRIMARY KEY("item_id","required_id")
+CREATE TABLE IF NOT EXISTS "messages" (
+ "id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
+ "user_id" uuid NOT NULL,
+ "parent_id" uuid,
+ "message" text NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone
);
--> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "research_required_items" (
- "research_id" integer NOT NULL,
- "item_id" integer NOT NULL,
- "quantity" integer NOT NULL,
- "description" text NOT NULL,
- CONSTRAINT "research_required_items_research_id_item_id_pk" PRIMARY KEY("research_id","item_id")
+ALTER TABLE "messages" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "user_follows" (
+ "user_id" uuid NOT NULL,
+ "following_user_id" uuid NOT NULL,
+ CONSTRAINT "user_follows_pk" PRIMARY KEY("user_id","following_user_id")
);
--> statement-breakpoint
-CREATE TABLE IF NOT EXISTS "upgrade_required_items" (
- "upgrade_id" integer NOT NULL,
- "item_id" integer NOT NULL,
- "quantity" integer NOT NULL,
- "description" text NOT NULL,
- CONSTRAINT "upgrade_required_items_upgrade_id_item_id_pk" PRIMARY KEY("upgrade_id","item_id")
+ALTER TABLE "user_follows" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "users" (
+ "id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
+ "user_id" uuid,
+ "username" text NOT NULL,
+ "email" text NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone,
+ "bio" text,
+ "avatar" text
);
--> statement-breakpoint
+ALTER TABLE "users" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "characters" ADD CONSTRAINT "characters_city_id_cities_id_fk" FOREIGN KEY ("city_id") REFERENCES "public"."cities"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "items_required_items" ADD CONSTRAINT "items_required_items_item_id_shop_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "characters" ADD CONSTRAINT "characters_element_id_elements_id_fk" FOREIGN KEY ("element_id") REFERENCES "public"."elements"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "items_required_items" ADD CONSTRAINT "items_required_items_required_id_shop_items_id_fk" FOREIGN KEY ("required_id") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "levels" ADD CONSTRAINT "levels_upgrade_id_upgrades_id_fk" FOREIGN KEY ("upgrade_id") REFERENCES "public"."upgrades"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "items_required_research" ADD CONSTRAINT "items_required_research_item_id_shop_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "messages" ADD CONSTRAINT "messages_parent_id_messages_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."messages"("id") ON DELETE cascade ON UPDATE cascade;
+ ALTER TABLE "items_required_research" ADD CONSTRAINT "items_required_research_required_id_research_id_fk" FOREIGN KEY ("required_id") REFERENCES "public"."research"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "messages" ADD CONSTRAINT "messages_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;
+ ALTER TABLE "levels" ADD CONSTRAINT "levels_upgrade_id_upgrades_id_fk" FOREIGN KEY ("upgrade_id") REFERENCES "public"."upgrades"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "tilez_games" ADD CONSTRAINT "tilez_games_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth"."users"("id") ON DELETE cascade ON UPDATE cascade;
+ ALTER TABLE "research_required_items" ADD CONSTRAINT "research_required_items_research_id_research_id_fk" FOREIGN KEY ("research_id") REFERENCES "public"."research"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "todos" ADD CONSTRAINT "todos_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth"."users"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "research_required_items" ADD CONSTRAINT "research_required_items_item_id_shop_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "upgrades" ADD CONSTRAINT "upgrades_effectItemId_shop_items_id_fk" FOREIGN KEY ("effectItemId") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "research_required_research" ADD CONSTRAINT "research_required_research_research_id_research_id_fk" FOREIGN KEY ("research_id") REFERENCES "public"."research"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "users" ADD CONSTRAINT "users_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth"."users"("id") ON DELETE cascade ON UPDATE cascade;
+ ALTER TABLE "research_required_research" ADD CONSTRAINT "research_required_research_required_id_research_id_fk" FOREIGN KEY ("required_id") REFERENCES "public"."research"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "hashtag_messages" ADD CONSTRAINT "hashtag_messages_hashtag_id_hashtags_id_fk" FOREIGN KEY ("hashtag_id") REFERENCES "public"."hashtags"("id") ON DELETE restrict ON UPDATE cascade;
+ ALTER TABLE "upgrade_required_items" ADD CONSTRAINT "upgrade_required_items_upgrade_id_upgrades_id_fk" FOREIGN KEY ("upgrade_id") REFERENCES "public"."upgrades"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "hashtag_messages" ADD CONSTRAINT "hashtag_messages_message_id_messages_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."messages"("id") ON DELETE cascade ON UPDATE cascade;
+ ALTER TABLE "upgrade_required_items" ADD CONSTRAINT "upgrade_required_items_item_id_shop_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "user_follows" ADD CONSTRAINT "user_follows_following_user_id_users_id_fk" FOREIGN KEY ("following_user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;
+ ALTER TABLE "upgrade_required_research" ADD CONSTRAINT "upgrade_required_research_upgrade_id_upgrades_id_fk" FOREIGN KEY ("upgrade_id") REFERENCES "public"."upgrades"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "user_follows" ADD CONSTRAINT "user_follows_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;
+ ALTER TABLE "upgrade_required_research" ADD CONSTRAINT "upgrade_required_research_required_id_research_id_fk" FOREIGN KEY ("required_id") REFERENCES "public"."research"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "items_required_research" ADD CONSTRAINT "items_required_research_item_id_shop_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "upgrades" ADD CONSTRAINT "upgrades_effectItemId_shop_items_id_fk" FOREIGN KEY ("effectItemId") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "items_required_research" ADD CONSTRAINT "items_required_research_required_id_research_id_fk" FOREIGN KEY ("required_id") REFERENCES "public"."research"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "characters" ADD CONSTRAINT "characters_element_id_elements_id_fk" FOREIGN KEY ("element_id") REFERENCES "public"."elements"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "likes" ADD CONSTRAINT "likes_message_id_messages_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."messages"("id") ON DELETE cascade ON UPDATE cascade;
+ ALTER TABLE "characters" ADD CONSTRAINT "characters_city_id_cities_id_fk" FOREIGN KEY ("city_id") REFERENCES "public"."cities"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "likes" ADD CONSTRAINT "likes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;
+ ALTER TABLE "todos" ADD CONSTRAINT "todos_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth"."users"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "research_required_research" ADD CONSTRAINT "research_required_research_required_id_research_id_fk" FOREIGN KEY ("required_id") REFERENCES "public"."research"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "tilez_games" ADD CONSTRAINT "tilez_games_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth"."users"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "research_required_research" ADD CONSTRAINT "research_required_research_research_id_research_id_fk" FOREIGN KEY ("research_id") REFERENCES "public"."research"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "hashtag_messages" ADD CONSTRAINT "hashtag_messages_hashtag_id_hashtags_id_fk" FOREIGN KEY ("hashtag_id") REFERENCES "public"."hashtags"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "upgrade_required_research" ADD CONSTRAINT "upgrade_required_research_required_id_research_id_fk" FOREIGN KEY ("required_id") REFERENCES "public"."research"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "hashtag_messages" ADD CONSTRAINT "hashtag_messages_message_id_messages_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."messages"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "upgrade_required_research" ADD CONSTRAINT "upgrade_required_research_upgrade_id_upgrades_id_fk" FOREIGN KEY ("upgrade_id") REFERENCES "public"."upgrades"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "likes" ADD CONSTRAINT "likes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "items_required_items" ADD CONSTRAINT "items_required_items_item_id_shop_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "likes" ADD CONSTRAINT "likes_message_id_messages_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."messages"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "items_required_items" ADD CONSTRAINT "items_required_items_required_id_shop_items_id_fk" FOREIGN KEY ("required_id") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "messages" ADD CONSTRAINT "messages_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "research_required_items" ADD CONSTRAINT "research_required_items_item_id_shop_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "messages" ADD CONSTRAINT "messages_parent_id_messages_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."messages"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "research_required_items" ADD CONSTRAINT "research_required_items_research_id_research_id_fk" FOREIGN KEY ("research_id") REFERENCES "public"."research"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "user_follows" ADD CONSTRAINT "user_follows_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "upgrade_required_items" ADD CONSTRAINT "upgrade_required_items_item_id_shop_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."shop_items"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "user_follows" ADD CONSTRAINT "user_follows_following_user_id_users_id_fk" FOREIGN KEY ("following_user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
- ALTER TABLE "upgrade_required_items" ADD CONSTRAINT "upgrade_required_items_upgrade_id_upgrades_id_fk" FOREIGN KEY ("upgrade_id") REFERENCES "public"."upgrades"("id") ON DELETE no action ON UPDATE no action;
+ ALTER TABLE "users" ADD CONSTRAINT "users_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth"."users"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
-CREATE INDEX IF NOT EXISTS "hashtags_hashtag_idx" ON "hashtags" USING btree ("hashtag");--> statement-breakpoint
-CREATE INDEX IF NOT EXISTS "messages_parent_id_idx" ON "messages" USING btree ("parent_id");--> statement-breakpoint
-CREATE INDEX IF NOT EXISTS "messages_user_id_idx" ON "messages" USING btree ("user_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "characters_city_id_cities_id_fk" ON "characters" USING btree ("city_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "characters_element_id_elements_id_fk" ON "characters" USING btree ("element_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "todos_user_id_idx" ON "todos" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "tilez_game_id_idx" ON "tilez_games" USING btree ("game_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "tilez_game_user_id_idx" ON "tilez_games" USING btree ("user_id");--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "tilez_word_word_idx" ON "tilez_words" USING btree ("word");--> statement-breakpoint
-CREATE INDEX IF NOT EXISTS "todos_user_id_idx" ON "todos" USING btree ("user_id");--> statement-breakpoint
-CREATE INDEX IF NOT EXISTS "users_email_idx" ON "users" USING btree ("email");--> statement-breakpoint
-CREATE INDEX IF NOT EXISTS "users_user_id_idx" ON "users" USING btree ("user_id");--> statement-breakpoint
-CREATE INDEX IF NOT EXISTS "users_username_idx" ON "users" USING btree ("username");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "hashtag_messages_hashtag_id_idx" ON "hashtag_messages" USING btree ("hashtag_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "hashtag_messages_message_id_idx" ON "hashtag_messages" USING btree ("message_id");--> statement-breakpoint
-CREATE INDEX IF NOT EXISTS "user_follows_following_user_id_idx" ON "user_follows" USING btree ("following_user_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "hashtags_hashtag_idx" ON "hashtags" USING btree ("hashtag");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "messages_user_id_idx" ON "messages" USING btree ("user_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "messages_parent_id_idx" ON "messages" USING btree ("parent_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "user_follows_user_id_idx" ON "user_follows" USING btree ("user_id");--> statement-breakpoint
-CREATE POLICY "hashtags_delete_policy" ON "hashtags" AS PERMISSIVE FOR DELETE TO "authenticated" USING (true);--> statement-breakpoint
-CREATE POLICY "hashtags_insert_policy" ON "hashtags" AS PERMISSIVE FOR INSERT TO "authenticated";--> statement-breakpoint
-CREATE POLICY "hashtags_select_policy" ON "hashtags" AS PERMISSIVE FOR SELECT TO public;--> statement-breakpoint
-CREATE POLICY "hashtags_update_policy" ON "hashtags" AS PERMISSIVE FOR UPDATE TO "authenticated";--> statement-breakpoint
-CREATE POLICY "messages_delete_policy" ON "messages" AS PERMISSIVE FOR DELETE TO "authenticated" USING ((user_id IN ( SELECT users.id
- FROM users
- WHERE (users.user_id = ( SELECT auth.uid() AS uid)))));--> statement-breakpoint
-CREATE POLICY "messages_insert_policy" ON "messages" AS PERMISSIVE FOR INSERT TO "authenticated";--> statement-breakpoint
-CREATE POLICY "messages_select_policy" ON "messages" AS PERMISSIVE FOR SELECT TO public;--> statement-breakpoint
-CREATE POLICY "messages_update_policy" ON "messages" AS PERMISSIVE FOR UPDATE TO public;--> statement-breakpoint
-CREATE POLICY "tilez_delete_policy" ON "tilez_games" AS PERMISSIVE FOR DELETE TO "authenticated" USING ((( SELECT auth.uid() AS uid) = user_id));--> statement-breakpoint
-CREATE POLICY "tilez_insert_policy" ON "tilez_games" AS PERMISSIVE FOR INSERT TO "authenticated";--> statement-breakpoint
-CREATE POLICY "tilez_select_policy" ON "tilez_games" AS PERMISSIVE FOR SELECT TO public;--> statement-breakpoint
-CREATE POLICY "tilez_update_policy" ON "tilez_games" AS PERMISSIVE FOR UPDATE TO public;--> statement-breakpoint
-CREATE POLICY "todos_delete_policy" ON "todos" AS PERMISSIVE FOR DELETE TO "authenticated" USING ((( SELECT auth.uid() AS uid) = user_id));--> statement-breakpoint
-CREATE POLICY "todos_insert_policy" ON "todos" AS PERMISSIVE FOR INSERT TO "authenticated";--> statement-breakpoint
-CREATE POLICY "todos_select_policy" ON "todos" AS PERMISSIVE FOR SELECT TO public;--> statement-breakpoint
-CREATE POLICY "todos_update_policy" ON "todos" AS PERMISSIVE FOR UPDATE TO public;--> statement-breakpoint
-CREATE POLICY "users_delete_policy" ON "users" AS PERMISSIVE FOR DELETE TO "authenticated" USING ((( SELECT auth.uid() AS uid) = user_id));--> statement-breakpoint
-CREATE POLICY "users_insert_policy" ON "users" AS PERMISSIVE FOR INSERT TO "authenticated";--> statement-breakpoint
-CREATE POLICY "users_select_policy" ON "users" AS PERMISSIVE FOR SELECT TO public;--> statement-breakpoint
-CREATE POLICY "users_update_policy" ON "users" AS PERMISSIVE FOR UPDATE TO public;--> statement-breakpoint
-CREATE POLICY "hashtag_messages_delete_policy" ON "hashtag_messages" AS PERMISSIVE FOR DELETE TO "authenticated" USING (true);--> statement-breakpoint
-CREATE POLICY "hashtag_messages_insert_policy" ON "hashtag_messages" AS PERMISSIVE FOR INSERT TO "authenticated";--> statement-breakpoint
-CREATE POLICY "hashtag_messages_select_policy" ON "hashtag_messages" AS PERMISSIVE FOR SELECT TO public;--> statement-breakpoint
-CREATE POLICY "hashtag_messages_update_policy" ON "hashtag_messages" AS PERMISSIVE FOR UPDATE TO "authenticated";--> statement-breakpoint
-CREATE POLICY "user_follows_delete_policy" ON "user_follows" AS PERMISSIVE FOR DELETE TO "authenticated" USING ((user_id IN ( SELECT users.id
- FROM users
- WHERE (users.user_id = ( SELECT auth.uid() AS uid)))));--> statement-breakpoint
-CREATE POLICY "user_follows_insert_policy" ON "user_follows" AS PERMISSIVE FOR INSERT TO "authenticated";--> statement-breakpoint
-CREATE POLICY "user_follows_select_policy" ON "user_follows" AS PERMISSIVE FOR SELECT TO public;--> statement-breakpoint
-CREATE POLICY "user_follows_update_policy" ON "user_follows" AS PERMISSIVE FOR UPDATE TO public;--> statement-breakpoint
-CREATE POLICY "likes_delete_policy" ON "likes" AS PERMISSIVE FOR DELETE TO "authenticated" USING ((user_id IN ( SELECT users.id
- FROM users
- WHERE (users.user_id = ( SELECT auth.uid() AS uid)))));--> statement-breakpoint
-CREATE POLICY "likes_insert_policy" ON "likes" AS PERMISSIVE FOR INSERT TO "authenticated";--> statement-breakpoint
-CREATE POLICY "likes_select_policy" ON "likes" AS PERMISSIVE FOR SELECT TO public;--> statement-breakpoint
-CREATE POLICY "likes_update_policy" ON "likes" AS PERMISSIVE FOR UPDATE TO public;
-*/
\ No newline at end of file
+CREATE INDEX IF NOT EXISTS "user_follows_following_user_id_idx" ON "user_follows" USING btree ("following_user_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "users_username_idx" ON "users" USING btree ("username");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "users_email_idx" ON "users" USING btree ("email");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "users_user_id_idx" ON "users" USING btree ("user_id");--> statement-breakpoint
+CREATE POLICY "todos_delete_policy" ON "todos" AS PERMISSIVE FOR DELETE TO "authenticated" USING ("todos"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "todos_insert_policy" ON "todos" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("todos"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "todos_select_policy" ON "todos" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("todos"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "todos_update_policy" ON "todos" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ("todos"."user_id" = (select auth.uid())) WITH CHECK ("todos"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "tilez_delete_policy" ON "tilez_games" AS PERMISSIVE FOR DELETE TO "authenticated" USING ("tilez_games"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "tilez_insert_policy" ON "tilez_games" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("tilez_games"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "tilez_select_policy" ON "tilez_games" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("tilez_games"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "tilez_update_policy" ON "tilez_games" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ("tilez_games"."user_id" = (select auth.uid())) WITH CHECK ("tilez_games"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "tilez_delete_word_policy" ON "tilez_words" AS PERMISSIVE FOR DELETE TO "postgres";--> statement-breakpoint
+CREATE POLICY "tilez_insert_word_policy" ON "tilez_words" AS PERMISSIVE FOR INSERT TO "postgres";--> statement-breakpoint
+CREATE POLICY "tilez_select_word_policy" ON "tilez_words" AS PERMISSIVE FOR SELECT TO "postgres";--> statement-breakpoint
+CREATE POLICY "tilez_update_word_policy" ON "tilez_words" AS PERMISSIVE FOR UPDATE TO "postgres";--> statement-breakpoint
+CREATE POLICY "hashtag_messages_delete_policy" ON "hashtag_messages" AS PERMISSIVE FOR DELETE TO "postgres" USING (true);--> statement-breakpoint
+CREATE POLICY "hashtag_messages_insert_policy" ON "hashtag_messages" AS PERMISSIVE FOR INSERT TO "postgres" WITH CHECK (true);--> statement-breakpoint
+CREATE POLICY "hashtag_messages_select_policy" ON "hashtag_messages" AS PERMISSIVE FOR SELECT TO "anon" USING (true);--> statement-breakpoint
+CREATE POLICY "hashtag_messages_update_policy" ON "hashtag_messages" AS PERMISSIVE FOR UPDATE TO "postgres" USING (true);--> statement-breakpoint
+CREATE POLICY "hashtags_delete_policy" ON "hashtags" AS PERMISSIVE FOR DELETE TO "postgres" USING (true);--> statement-breakpoint
+CREATE POLICY "hashtags_insert_policy" ON "hashtags" AS PERMISSIVE FOR INSERT TO "postgres" WITH CHECK (true);--> statement-breakpoint
+CREATE POLICY "hashtags_select_policy" ON "hashtags" AS PERMISSIVE FOR SELECT TO "anon" USING (true);--> statement-breakpoint
+CREATE POLICY "hashtags_update_policy" ON "hashtags" AS PERMISSIVE FOR UPDATE TO "postgres" USING (true);--> statement-breakpoint
+CREATE POLICY "likes_delete_policy" ON "likes" AS PERMISSIVE FOR DELETE TO "authenticated" USING ((user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid)))));--> statement-breakpoint
+CREATE POLICY "likes_insert_policy" ON "likes" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ((user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid)))));--> statement-breakpoint
+CREATE POLICY "likes_select_policy" ON "likes" AS PERMISSIVE FOR SELECT TO "anon" USING (true);--> statement-breakpoint
+CREATE POLICY "likes_update_policy" ON "likes" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ((user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))) WITH CHECK ((user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid)))));--> statement-breakpoint
+CREATE POLICY "messages_delete_policy" ON "messages" AS PERMISSIVE FOR DELETE TO "authenticated" USING ("messages"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "messages_insert_policy" ON "messages" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("messages"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "messages_select_policy" ON "messages" AS PERMISSIVE FOR SELECT TO "anon" USING (true);--> statement-breakpoint
+CREATE POLICY "messages_update_policy" ON "messages" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ("messages"."user_id" = (select auth.uid())) WITH CHECK ("messages"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "user_follows_delete_policy" ON "user_follows" AS PERMISSIVE FOR DELETE TO "authenticated" USING ((user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid)))));--> statement-breakpoint
+CREATE POLICY "user_follows_insert_policy" ON "user_follows" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ((user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid)))));--> statement-breakpoint
+CREATE POLICY "user_follows_select_policy" ON "user_follows" AS PERMISSIVE FOR SELECT TO "anon" USING (true);--> statement-breakpoint
+CREATE POLICY "user_follows_update_policy" ON "user_follows" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ((user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))) WITH CHECK ((user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid)))));--> statement-breakpoint
+CREATE POLICY "users_delete_policy" ON "users" AS PERMISSIVE FOR DELETE TO "authenticated" USING ("users"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "users_insert_policy" ON "users" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("users"."user_id" = (select auth.uid()));--> statement-breakpoint
+CREATE POLICY "users_select_policy" ON "users" AS PERMISSIVE FOR SELECT TO "anon" USING (true);--> statement-breakpoint
+CREATE POLICY "users_update_policy" ON "users" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ("users"."user_id" = (select auth.uid())) WITH CHECK ("users"."user_id" = (select auth.uid()));
\ No newline at end of file
diff --git a/src/db/migrations/meta/20241030170954_snapshot.json b/src/db/migrations/meta/20250117221840_snapshot.json
similarity index 87%
rename from src/db/migrations/meta/20241030170954_snapshot.json
rename to src/db/migrations/meta/20250117221840_snapshot.json
index db08218..748029a 100644
--- a/src/db/migrations/meta/20241030170954_snapshot.json
+++ b/src/db/migrations/meta/20250117221840_snapshot.json
@@ -1,201 +1,9 @@
{
- "id": "00000000-0000-0000-0000-000000000000",
- "prevId": "",
+ "id": "85b0c8e8-e7e8-4777-be77-ded0912bb7d7",
+ "prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
- "public.characters": {
- "name": "characters",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "integer",
- "primaryKey": true,
- "notNull": true,
- "identity": {
- "type": "always",
- "name": "characters_id_seq",
- "increment": "1",
- "minValue": "1",
- "maxValue": "2147483647",
- "startWith": "1",
- "cache": "1",
- "cycle": false,
- "schema": "public"
- }
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text[]",
- "primaryKey": false,
- "notNull": true
- },
- "element_id": {
- "name": "element_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "city_id": {
- "name": "city_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {
- "characters_city_id_cities_id_fk": {
- "name": "characters_city_id_cities_id_fk",
- "tableFrom": "characters",
- "tableTo": "cities",
- "schemaTo": "public",
- "columnsFrom": [
- "city_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "characters_element_id_elements_id_fk": {
- "name": "characters_element_id_elements_id_fk",
- "tableFrom": "characters",
- "tableTo": "elements",
- "schemaTo": "public",
- "columnsFrom": [
- "element_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "characters_name_unique": {
- "columns": [
- "name"
- ],
- "nullsNotDistinct": false,
- "name": "characters_name_unique"
- }
- },
- "checkConstraints": {},
- "policies": {},
- "isRLSEnabled": false
- },
- "public.cities": {
- "name": "cities",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "integer",
- "primaryKey": true,
- "notNull": true,
- "identity": {
- "type": "always",
- "name": "cities_id_seq",
- "increment": "1",
- "minValue": "1",
- "maxValue": "2147483647",
- "startWith": "1",
- "cache": "1",
- "cycle": false,
- "schema": "public"
- }
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "cities_name_unique": {
- "columns": [
- "name"
- ],
- "nullsNotDistinct": false,
- "name": "cities_name_unique"
- }
- },
- "checkConstraints": {},
- "policies": {},
- "isRLSEnabled": false
- },
- "public.elements": {
- "name": "elements",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "integer",
- "primaryKey": true,
- "notNull": true,
- "identity": {
- "type": "always",
- "name": "elements_id_seq",
- "increment": "1",
- "minValue": "1",
- "maxValue": "2147483647",
- "startWith": "1",
- "cache": "1",
- "cycle": false,
- "schema": "public"
- }
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "colour": {
- "name": "colour",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "elements_name_unique": {
- "columns": [
- "name"
- ],
- "nullsNotDistinct": false,
- "name": "elements_name_unique"
- },
- "elements_colour_unique": {
- "columns": [
- "colour"
- ],
- "nullsNotDistinct": false,
- "name": "elements_colour_unique"
- }
- },
- "checkConstraints": {},
- "policies": {},
- "isRLSEnabled": false
- },
"public.gamestate": {
"name": "gamestate",
"schema": "",
@@ -208,13 +16,13 @@
"identity": {
"type": "always",
"name": "gamestats_id_seq",
+ "schema": "public",
"increment": "1",
+ "startWith": "1",
"minValue": "1",
"maxValue": "2147483647",
- "startWith": "1",
"cache": "1",
- "cycle": false,
- "schema": "public"
+ "cycle": false
}
},
"playername": {
@@ -282,86 +90,147 @@
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
- "checkConstraints": {},
"policies": {},
+ "checkConstraints": {},
"isRLSEnabled": false
},
- "public.hashtags": {
- "name": "hashtags",
+ "public.items_required_items": {
+ "name": "items_required_items",
"schema": "",
"columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "uuid_generate_v4()"
+ "item_id": {
+ "name": "item_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
},
- "hashtag": {
- "name": "hashtag",
+ "required_id": {
+ "name": "required_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
- "indexes": {
- "hashtags_hashtag_idx": {
- "name": "hashtags_hashtag_idx",
- "columns": [
- {
- "expression": "hashtag",
- "asc": true,
- "nulls": "last",
- "opclass": "text_ops",
- "isExpression": false
- }
+ "indexes": {},
+ "foreignKeys": {
+ "items_required_items_item_id_shop_items_id_fk": {
+ "name": "items_required_items_item_id_shop_items_id_fk",
+ "tableFrom": "items_required_items",
+ "tableTo": "shop_items",
+ "columnsFrom": [
+ "item_id"
],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {},
- "policies": {
- "hashtags_delete_policy": {
- "name": "hashtags_delete_policy",
- "as": "PERMISSIVE",
- "for": "DELETE",
- "to": [
- "authenticated"
+ "columnsTo": [
+ "id"
],
- "using": "true"
+ "onDelete": "no action",
+ "onUpdate": "no action"
},
- "hashtags_insert_policy": {
- "name": "hashtags_insert_policy",
- "as": "PERMISSIVE",
- "for": "INSERT",
- "to": [
- "authenticated"
+ "items_required_items_required_id_shop_items_id_fk": {
+ "name": "items_required_items_required_id_shop_items_id_fk",
+ "tableFrom": "items_required_items",
+ "tableTo": "shop_items",
+ "columnsFrom": [
+ "required_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "items_required_items_item_id_required_id_pk": {
+ "name": "items_required_items_item_id_required_id_pk",
+ "columns": [
+ "item_id",
+ "required_id"
]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.items_required_research": {
+ "name": "items_required_research",
+ "schema": "",
+ "columns": {
+ "item_id": {
+ "name": "item_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
},
- "hashtags_select_policy": {
- "name": "hashtags_select_policy",
- "as": "PERMISSIVE",
- "for": "SELECT",
- "to": [
- "public"
- ]
+ "required_id": {
+ "name": "required_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
},
- "hashtags_update_policy": {
- "name": "hashtags_update_policy",
- "as": "PERMISSIVE",
- "for": "UPDATE",
- "to": [
- "authenticated"
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "items_required_research_item_id_shop_items_id_fk": {
+ "name": "items_required_research_item_id_shop_items_id_fk",
+ "tableFrom": "items_required_research",
+ "tableTo": "shop_items",
+ "columnsFrom": [
+ "item_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "items_required_research_required_id_research_id_fk": {
+ "name": "items_required_research_required_id_research_id_fk",
+ "tableFrom": "items_required_research",
+ "tableTo": "research",
+ "columnsFrom": [
+ "required_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "items_required_research_item_id_required_id_pk": {
+ "name": "items_required_research_item_id_required_id_pk",
+ "columns": [
+ "item_id",
+ "required_id"
]
}
},
- "isRLSEnabled": true
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
},
"public.levels": {
"name": "levels",
@@ -375,13 +244,13 @@
"identity": {
"type": "always",
"name": "levels_id_seq",
+ "schema": "public",
"increment": "1",
+ "startWith": "1",
"minValue": "1",
"maxValue": "2147483647",
- "startWith": "1",
"cache": "1",
- "cycle": false,
- "schema": "public"
+ "cycle": false
}
},
"level": {
@@ -427,7 +296,6 @@
"name": "levels_upgrade_id_upgrades_id_fk",
"tableFrom": "levels",
"tableTo": "upgrades",
- "schemaTo": "public",
"columnsFrom": [
"upgrade_id"
],
@@ -440,156 +308,9 @@
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
- "checkConstraints": {},
"policies": {},
- "isRLSEnabled": false
- },
- "public.messages": {
- "name": "messages",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "uuid_generate_v4()"
- },
- "user_id": {
- "name": "user_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "parent_id": {
- "name": "parent_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
- },
- "message": {
- "name": "message",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "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": false
- }
- },
- "indexes": {
- "messages_parent_id_idx": {
- "name": "messages_parent_id_idx",
- "columns": [
- {
- "expression": "parent_id",
- "asc": true,
- "nulls": "last",
- "opclass": "uuid_ops",
- "isExpression": false
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "messages_user_id_idx": {
- "name": "messages_user_id_idx",
- "columns": [
- {
- "expression": "user_id",
- "asc": true,
- "nulls": "last",
- "opclass": "uuid_ops",
- "isExpression": false
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "messages_parent_id_messages_id_fk": {
- "name": "messages_parent_id_messages_id_fk",
- "tableFrom": "messages",
- "tableTo": "messages",
- "schemaTo": "public",
- "columnsFrom": [
- "parent_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- },
- "messages_user_id_users_id_fk": {
- "name": "messages_user_id_users_id_fk",
- "tableFrom": "messages",
- "tableTo": "users",
- "schemaTo": "public",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "cascade",
- "onUpdate": "cascade"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
"checkConstraints": {},
- "policies": {
- "messages_delete_policy": {
- "name": "messages_delete_policy",
- "as": "PERMISSIVE",
- "for": "DELETE",
- "to": [
- "authenticated"
- ],
- "using": "(user_id IN ( SELECT users.id\n FROM users\n WHERE (users.user_id = ( SELECT auth.uid() AS uid))))"
- },
- "messages_insert_policy": {
- "name": "messages_insert_policy",
- "as": "PERMISSIVE",
- "for": "INSERT",
- "to": [
- "authenticated"
- ]
- },
- "messages_select_policy": {
- "name": "messages_select_policy",
- "as": "PERMISSIVE",
- "for": "SELECT",
- "to": [
- "public"
- ]
- },
- "messages_update_policy": {
- "name": "messages_update_policy",
- "as": "PERMISSIVE",
- "for": "UPDATE",
- "to": [
- "public"
- ]
- }
- },
- "isRLSEnabled": true
+ "isRLSEnabled": false
},
"public.research": {
"name": "research",
@@ -603,13 +324,13 @@
"identity": {
"type": "always",
"name": "research_id_seq",
+ "schema": "public",
"increment": "1",
+ "startWith": "1",
"minValue": "1",
"maxValue": "2147483647",
- "startWith": "1",
"cache": "1",
- "cycle": false,
- "schema": "public"
+ "cycle": false
}
},
"name": {
@@ -635,29 +356,167 @@
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
- "checkConstraints": {},
"policies": {},
+ "checkConstraints": {},
"isRLSEnabled": false
},
- "public.shop_items": {
- "name": "shop_items",
+ "public.research_required_items": {
+ "name": "research_required_items",
"schema": "",
"columns": {
- "id": {
- "name": "id",
+ "research_id": {
+ "name": "research_id",
"type": "integer",
- "primaryKey": true,
- "notNull": true,
- "identity": {
+ "primaryKey": false,
+ "notNull": true
+ },
+ "item_id": {
+ "name": "item_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "research_required_items_research_id_research_id_fk": {
+ "name": "research_required_items_research_id_research_id_fk",
+ "tableFrom": "research_required_items",
+ "tableTo": "research",
+ "columnsFrom": [
+ "research_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "research_required_items_item_id_shop_items_id_fk": {
+ "name": "research_required_items_item_id_shop_items_id_fk",
+ "tableFrom": "research_required_items",
+ "tableTo": "shop_items",
+ "columnsFrom": [
+ "item_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "research_required_items_research_id_item_id_pk": {
+ "name": "research_required_items_research_id_item_id_pk",
+ "columns": [
+ "research_id",
+ "item_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.research_required_research": {
+ "name": "research_required_research",
+ "schema": "",
+ "columns": {
+ "research_id": {
+ "name": "research_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "required_id": {
+ "name": "required_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "research_required_research_research_id_research_id_fk": {
+ "name": "research_required_research_research_id_research_id_fk",
+ "tableFrom": "research_required_research",
+ "tableTo": "research",
+ "columnsFrom": [
+ "research_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "research_required_research_required_id_research_id_fk": {
+ "name": "research_required_research_required_id_research_id_fk",
+ "tableFrom": "research_required_research",
+ "tableTo": "research",
+ "columnsFrom": [
+ "required_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "research_required_research_research_id_required_id_pk": {
+ "name": "research_required_research_research_id_required_id_pk",
+ "columns": [
+ "research_id",
+ "required_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.shop_items": {
+ "name": "shop_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "identity": {
"type": "always",
"name": "shop_items_id_seq",
+ "schema": "public",
"increment": "1",
+ "startWith": "1",
"minValue": "1",
"maxValue": "2147483647",
- "startWith": "1",
"cache": "1",
- "cycle": false,
- "schema": "public"
+ "cycle": false
}
},
"name": {
@@ -707,270 +566,126 @@
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
- "checkConstraints": {},
"policies": {},
+ "checkConstraints": {},
"isRLSEnabled": false
},
- "public.tilez_games": {
- "name": "tilez_games",
+ "public.upgrade_required_items": {
+ "name": "upgrade_required_items",
"schema": "",
"columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "uuid_generate_v4()"
- },
- "game_id": {
- "name": "game_id",
- "type": "text",
+ "upgrade_id": {
+ "name": "upgrade_id",
+ "type": "integer",
"primaryKey": false,
"notNull": true
},
- "user_id": {
- "name": "user_id",
- "type": "uuid",
+ "item_id": {
+ "name": "item_id",
+ "type": "integer",
"primaryKey": false,
"notNull": true
},
- "game_start": {
- "name": "game_start",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- },
- "game_end": {
- "name": "game_end",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "num_moves": {
- "name": "num_moves",
+ "quantity": {
+ "name": "quantity",
"type": "integer",
"primaryKey": false,
- "notNull": false,
- "default": 0
+ "notNull": true
},
- "completed": {
- "name": "completed",
- "type": "boolean",
+ "description": {
+ "name": "description",
+ "type": "text",
"primaryKey": false,
- "notNull": false,
- "default": false
+ "notNull": true
}
},
- "indexes": {
- "tilez_game_id_idx": {
- "name": "tilez_game_id_idx",
- "columns": [
- {
- "expression": "game_id",
- "asc": true,
- "nulls": "last",
- "opclass": "text_ops",
- "isExpression": false
- }
+ "indexes": {},
+ "foreignKeys": {
+ "upgrade_required_items_upgrade_id_upgrades_id_fk": {
+ "name": "upgrade_required_items_upgrade_id_upgrades_id_fk",
+ "tableFrom": "upgrade_required_items",
+ "tableTo": "upgrades",
+ "columnsFrom": [
+ "upgrade_id"
],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "tilez_game_user_id_idx": {
- "name": "tilez_game_user_id_idx",
- "columns": [
- {
- "expression": "user_id",
- "asc": true,
- "nulls": "last",
- "opclass": "uuid_ops",
- "isExpression": false
- }
+ "columnsTo": [
+ "id"
],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "tilez_games_user_id_users_id_fk": {
- "name": "tilez_games_user_id_users_id_fk",
- "tableFrom": "tilez_games",
- "tableTo": "users",
- "schemaTo": "auth",
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "upgrade_required_items_item_id_shop_items_id_fk": {
+ "name": "upgrade_required_items_item_id_shop_items_id_fk",
+ "tableFrom": "upgrade_required_items",
+ "tableTo": "shop_items",
"columnsFrom": [
- "user_id"
+ "item_id"
],
"columnsTo": [
"id"
],
- "onDelete": "cascade",
- "onUpdate": "cascade"
+ "onDelete": "no action",
+ "onUpdate": "no action"
}
},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {},
- "policies": {
- "tilez_delete_policy": {
- "name": "tilez_delete_policy",
- "as": "PERMISSIVE",
- "for": "DELETE",
- "to": [
- "authenticated"
- ],
- "using": "(( SELECT auth.uid() AS uid) = user_id)"
- },
- "tilez_insert_policy": {
- "name": "tilez_insert_policy",
- "as": "PERMISSIVE",
- "for": "INSERT",
- "to": [
- "authenticated"
- ]
- },
- "tilez_select_policy": {
- "name": "tilez_select_policy",
- "as": "PERMISSIVE",
- "for": "SELECT",
- "to": [
- "public"
- ]
- },
- "tilez_update_policy": {
- "name": "tilez_update_policy",
- "as": "PERMISSIVE",
- "for": "UPDATE",
- "to": [
- "public"
- ]
- }
- },
- "isRLSEnabled": true
- },
- "public.tilez_words": {
- "name": "tilez_words",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "uuid_generate_v4()"
- },
- "word": {
- "name": "word",
- "type": "char(6)",
- "primaryKey": false,
- "notNull": true
- },
- "definition": {
- "name": "definition",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "last_checked": {
- "name": "last_checked",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "tilez_word_word_idx": {
- "name": "tilez_word_word_idx",
+ "compositePrimaryKeys": {
+ "upgrade_required_items_upgrade_id_item_id_pk": {
+ "name": "upgrade_required_items_upgrade_id_item_id_pk",
"columns": [
- {
- "expression": "word",
- "asc": true,
- "nulls": "last",
- "opclass": "bpchar_ops",
- "isExpression": false
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
+ "upgrade_id",
+ "item_id"
+ ]
}
},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
"uniqueConstraints": {},
- "checkConstraints": {},
"policies": {},
- "isRLSEnabled": true
+ "checkConstraints": {},
+ "isRLSEnabled": false
},
- "public.todos": {
- "name": "todos",
+ "public.upgrade_required_research": {
+ "name": "upgrade_required_research",
"schema": "",
"columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "uuid_generate_v4()"
- },
- "title": {
- "name": "title",
- "type": "text",
+ "upgrade_id": {
+ "name": "upgrade_id",
+ "type": "integer",
"primaryKey": false,
"notNull": true
},
- "completed": {
- "name": "completed",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
- },
- "user_id": {
- "name": "user_id",
- "type": "uuid",
+ "required_id": {
+ "name": "required_id",
+ "type": "integer",
"primaryKey": false,
"notNull": true
},
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
+ "description": {
+ "name": "description",
+ "type": "text",
"primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "todos_user_id_idx": {
- "name": "todos_user_id_idx",
- "columns": [
- {
- "expression": "user_id",
- "asc": true,
- "nulls": "last",
- "opclass": "uuid_ops",
- "isExpression": false
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
+ "notNull": true
}
},
+ "indexes": {},
"foreignKeys": {
- "todos_user_id_users_id_fk": {
- "name": "todos_user_id_users_id_fk",
- "tableFrom": "todos",
- "tableTo": "users",
- "schemaTo": "auth",
+ "upgrade_required_research_upgrade_id_upgrades_id_fk": {
+ "name": "upgrade_required_research_upgrade_id_upgrades_id_fk",
+ "tableFrom": "upgrade_required_research",
+ "tableTo": "upgrades",
"columnsFrom": [
- "user_id"
+ "upgrade_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "upgrade_required_research_required_id_research_id_fk": {
+ "name": "upgrade_required_research_required_id_research_id_fk",
+ "tableFrom": "upgrade_required_research",
+ "tableTo": "research",
+ "columnsFrom": [
+ "required_id"
],
"columnsTo": [
"id"
@@ -979,45 +694,19 @@
"onUpdate": "no action"
}
},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "checkConstraints": {},
- "policies": {
- "todos_delete_policy": {
- "name": "todos_delete_policy",
- "as": "PERMISSIVE",
- "for": "DELETE",
- "to": [
- "authenticated"
- ],
- "using": "(( SELECT auth.uid() AS uid) = user_id)"
- },
- "todos_insert_policy": {
- "name": "todos_insert_policy",
- "as": "PERMISSIVE",
- "for": "INSERT",
- "to": [
- "authenticated"
- ]
- },
- "todos_select_policy": {
- "name": "todos_select_policy",
- "as": "PERMISSIVE",
- "for": "SELECT",
- "to": [
- "public"
- ]
- },
- "todos_update_policy": {
- "name": "todos_update_policy",
- "as": "PERMISSIVE",
- "for": "UPDATE",
- "to": [
- "public"
+ "compositePrimaryKeys": {
+ "upgrade_required_research_upgrade_id_research_id_pk": {
+ "name": "upgrade_required_research_upgrade_id_research_id_pk",
+ "columns": [
+ "upgrade_id",
+ "required_id"
]
}
},
- "isRLSEnabled": true
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
},
"public.upgrades": {
"name": "upgrades",
@@ -1031,13 +720,13 @@
"identity": {
"type": "always",
"name": "upgrades_id_seq",
+ "schema": "public",
"increment": "1",
+ "startWith": "1",
"minValue": "1",
"maxValue": "2147483647",
- "startWith": "1",
"cache": "1",
- "cycle": false,
- "schema": "public"
+ "cycle": false
}
},
"name": {
@@ -1065,7 +754,6 @@
"name": "upgrades_effectItemId_shop_items_id_fk",
"tableFrom": "upgrades",
"tableTo": "shop_items",
- "schemaTo": "public",
"columnsFrom": [
"effectItemId"
],
@@ -1078,75 +766,65 @@
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
- "checkConstraints": {},
"policies": {},
+ "checkConstraints": {},
"isRLSEnabled": false
},
- "public.users": {
- "name": "users",
+ "public.characters": {
+ "name": "characters",
"schema": "",
"columns": {
"id": {
"name": "id",
- "type": "uuid",
+ "type": "integer",
"primaryKey": true,
"notNull": true,
- "default": "uuid_generate_v4()"
- },
- "user_id": {
- "name": "user_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
+ "identity": {
+ "type": "always",
+ "name": "characters_id_seq",
+ "schema": "public",
+ "increment": "1",
+ "startWith": "1",
+ "minValue": "1",
+ "maxValue": "2147483647",
+ "cache": "1",
+ "cycle": false
+ }
},
- "username": {
- "name": "username",
+ "name": {
+ "name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "email": {
- "name": "email",
- "type": "text",
+ "description": {
+ "name": "description",
+ "type": "text[]",
"primaryKey": false,
"notNull": true
},
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
+ "element_id": {
+ "name": "element_id",
+ "type": "integer",
"primaryKey": false,
- "notNull": true,
- "default": "now()"
+ "notNull": true
},
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "bio": {
- "name": "bio",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "avatar": {
- "name": "avatar",
- "type": "text",
+ "city_id": {
+ "name": "city_id",
+ "type": "integer",
"primaryKey": false,
- "notNull": false
+ "notNull": true
}
},
"indexes": {
- "users_email_idx": {
- "name": "users_email_idx",
+ "characters_city_id_cities_id_fk": {
+ "name": "characters_city_id_cities_id_fk",
"columns": [
{
- "expression": "email",
+ "expression": "city_id",
+ "isExpression": false,
"asc": true,
- "nulls": "last",
- "opclass": "text_ops",
- "isExpression": false
+ "nulls": "last"
}
],
"isUnique": false,
@@ -1154,31 +832,212 @@
"method": "btree",
"with": {}
},
- "users_user_id_idx": {
- "name": "users_user_id_idx",
+ "characters_element_id_elements_id_fk": {
+ "name": "characters_element_id_elements_id_fk",
"columns": [
{
- "expression": "user_id",
+ "expression": "element_id",
+ "isExpression": false,
"asc": true,
- "nulls": "last",
- "opclass": "uuid_ops",
- "isExpression": false
+ "nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
+ }
+ },
+ "foreignKeys": {
+ "characters_element_id_elements_id_fk": {
+ "name": "characters_element_id_elements_id_fk",
+ "tableFrom": "characters",
+ "tableTo": "elements",
+ "columnsFrom": [
+ "element_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
},
- "users_username_idx": {
- "name": "users_username_idx",
+ "characters_city_id_cities_id_fk": {
+ "name": "characters_city_id_cities_id_fk",
+ "tableFrom": "characters",
+ "tableTo": "cities",
+ "columnsFrom": [
+ "city_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "characters_name_unique": {
+ "name": "characters_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cities": {
+ "name": "cities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "identity": {
+ "type": "always",
+ "name": "cities_id_seq",
+ "schema": "public",
+ "increment": "1",
+ "startWith": "1",
+ "minValue": "1",
+ "maxValue": "2147483647",
+ "cache": "1",
+ "cycle": false
+ }
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "cities_name_unique": {
+ "name": "cities_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.elements": {
+ "name": "elements",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "identity": {
+ "type": "always",
+ "name": "elements_id_seq",
+ "schema": "public",
+ "increment": "1",
+ "startWith": "1",
+ "minValue": "1",
+ "maxValue": "2147483647",
+ "cache": "1",
+ "cycle": false
+ }
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "colour": {
+ "name": "colour",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "elements_name_unique": {
+ "name": "elements_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "name"
+ ]
+ },
+ "elements_colour_unique": {
+ "name": "elements_colour_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "colour"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.todos": {
+ "name": "todos",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "uuid_generate_v4()"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed": {
+ "name": "completed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "todos_user_id_idx": {
+ "name": "todos_user_id_idx",
"columns": [
{
- "expression": "username",
+ "expression": "user_id",
+ "isExpression": false,
"asc": true,
- "nulls": "last",
- "opclass": "text_ops",
- "isExpression": false
+ "nulls": "last"
}
],
"isUnique": false,
@@ -1188,9 +1047,9 @@
}
},
"foreignKeys": {
- "users_user_id_users_id_fk": {
- "name": "users_user_id_users_id_fk",
- "tableFrom": "users",
+ "todos_user_id_users_id_fk": {
+ "name": "todos_user_id_users_id_fk",
+ "tableFrom": "todos",
"tableTo": "users",
"schemaTo": "auth",
"columnsFrom": [
@@ -1199,77 +1058,114 @@
"columnsTo": [
"id"
],
- "onDelete": "cascade",
- "onUpdate": "cascade"
+ "onDelete": "no action",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
- "checkConstraints": {},
"policies": {
- "users_delete_policy": {
- "name": "users_delete_policy",
+ "todos_delete_policy": {
+ "name": "todos_delete_policy",
"as": "PERMISSIVE",
"for": "DELETE",
"to": [
"authenticated"
],
- "using": "(( SELECT auth.uid() AS uid) = user_id)"
+ "using": "\"todos\".\"user_id\" = (select auth.uid())"
},
- "users_insert_policy": {
- "name": "users_insert_policy",
+ "todos_insert_policy": {
+ "name": "todos_insert_policy",
"as": "PERMISSIVE",
"for": "INSERT",
"to": [
"authenticated"
- ]
+ ],
+ "withCheck": "\"todos\".\"user_id\" = (select auth.uid())"
},
- "users_select_policy": {
- "name": "users_select_policy",
+ "todos_select_policy": {
+ "name": "todos_select_policy",
"as": "PERMISSIVE",
"for": "SELECT",
"to": [
- "public"
- ]
+ "authenticated"
+ ],
+ "using": "\"todos\".\"user_id\" = (select auth.uid())"
},
- "users_update_policy": {
- "name": "users_update_policy",
+ "todos_update_policy": {
+ "name": "todos_update_policy",
"as": "PERMISSIVE",
"for": "UPDATE",
"to": [
- "public"
- ]
+ "authenticated"
+ ],
+ "using": "\"todos\".\"user_id\" = (select auth.uid())",
+ "withCheck": "\"todos\".\"user_id\" = (select auth.uid())"
}
},
- "isRLSEnabled": true
+ "checkConstraints": {},
+ "isRLSEnabled": false
},
- "public.hashtag_messages": {
- "name": "hashtag_messages",
+ "public.tilez_games": {
+ "name": "tilez_games",
"schema": "",
"columns": {
- "hashtag_id": {
- "name": "hashtag_id",
+ "id": {
+ "name": "id",
"type": "uuid",
- "primaryKey": false,
- "notNull": true
+ "primaryKey": true,
+ "notNull": true,
+ "default": "uuid_generate_v4()"
},
- "message_id": {
- "name": "message_id",
+ "game_id": {
+ "name": "game_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
+ },
+ "game_start": {
+ "name": "game_start",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "game_end": {
+ "name": "game_end",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "num_moves": {
+ "name": "num_moves",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "completed": {
+ "name": "completed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
}
},
"indexes": {
- "hashtag_messages_hashtag_id_idx": {
- "name": "hashtag_messages_hashtag_id_idx",
+ "tilez_game_id_idx": {
+ "name": "tilez_game_id_idx",
"columns": [
{
- "expression": "hashtag_id",
+ "expression": "game_id",
+ "isExpression": false,
"asc": true,
- "nulls": "last",
- "opclass": "uuid_ops",
- "isExpression": false
+ "nulls": "last"
}
],
"isUnique": false,
@@ -1277,15 +1173,14 @@
"method": "btree",
"with": {}
},
- "hashtag_messages_message_id_idx": {
- "name": "hashtag_messages_message_id_idx",
+ "tilez_game_user_id_idx": {
+ "name": "tilez_game_user_id_idx",
"columns": [
{
- "expression": "message_id",
+ "expression": "user_id",
+ "isExpression": false,
"asc": true,
- "nulls": "last",
- "opclass": "uuid_ops",
- "isExpression": false
+ "nulls": "last"
}
],
"isUnique": false,
@@ -1295,110 +1190,178 @@
}
},
"foreignKeys": {
- "hashtag_messages_hashtag_id_hashtags_id_fk": {
- "name": "hashtag_messages_hashtag_id_hashtags_id_fk",
- "tableFrom": "hashtag_messages",
- "tableTo": "hashtags",
- "schemaTo": "public",
+ "tilez_games_user_id_users_id_fk": {
+ "name": "tilez_games_user_id_users_id_fk",
+ "tableFrom": "tilez_games",
+ "tableTo": "users",
+ "schemaTo": "auth",
"columnsFrom": [
- "hashtag_id"
+ "user_id"
],
"columnsTo": [
"id"
],
- "onDelete": "restrict",
+ "onDelete": "cascade",
"onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "tilez_delete_policy": {
+ "name": "tilez_delete_policy",
+ "as": "PERMISSIVE",
+ "for": "DELETE",
+ "to": [
+ "authenticated"
+ ],
+ "using": "\"tilez_games\".\"user_id\" = (select auth.uid())"
},
- "hashtag_messages_message_id_messages_id_fk": {
- "name": "hashtag_messages_message_id_messages_id_fk",
- "tableFrom": "hashtag_messages",
- "tableTo": "messages",
- "schemaTo": "public",
- "columnsFrom": [
- "message_id"
+ "tilez_insert_policy": {
+ "name": "tilez_insert_policy",
+ "as": "PERMISSIVE",
+ "for": "INSERT",
+ "to": [
+ "authenticated"
],
- "columnsTo": [
- "id"
+ "withCheck": "\"tilez_games\".\"user_id\" = (select auth.uid())"
+ },
+ "tilez_select_policy": {
+ "name": "tilez_select_policy",
+ "as": "PERMISSIVE",
+ "for": "SELECT",
+ "to": [
+ "authenticated"
],
- "onDelete": "cascade",
- "onUpdate": "cascade"
+ "using": "\"tilez_games\".\"user_id\" = (select auth.uid())"
+ },
+ "tilez_update_policy": {
+ "name": "tilez_update_policy",
+ "as": "PERMISSIVE",
+ "for": "UPDATE",
+ "to": [
+ "authenticated"
+ ],
+ "using": "\"tilez_games\".\"user_id\" = (select auth.uid())",
+ "withCheck": "\"tilez_games\".\"user_id\" = (select auth.uid())"
}
},
- "compositePrimaryKeys": {
- "hashtag_messages_pk": {
- "name": "hashtag_messages_pk",
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.tilez_words": {
+ "name": "tilez_words",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "uuid_generate_v4()"
+ },
+ "word": {
+ "name": "word",
+ "type": "char(6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "definition": {
+ "name": "definition",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_checked": {
+ "name": "last_checked",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "tilez_word_word_idx": {
+ "name": "tilez_word_word_idx",
"columns": [
- "hashtag_id",
- "message_id"
- ]
+ {
+ "expression": "word",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
"uniqueConstraints": {},
- "checkConstraints": {},
"policies": {
- "hashtag_messages_delete_policy": {
- "name": "hashtag_messages_delete_policy",
+ "tilez_delete_word_policy": {
+ "name": "tilez_delete_word_policy",
"as": "PERMISSIVE",
"for": "DELETE",
"to": [
- "authenticated"
- ],
- "using": "true"
+ "postgres_role"
+ ]
},
- "hashtag_messages_insert_policy": {
- "name": "hashtag_messages_insert_policy",
+ "tilez_insert_word_policy": {
+ "name": "tilez_insert_word_policy",
"as": "PERMISSIVE",
"for": "INSERT",
"to": [
- "authenticated"
+ "postgres_role"
]
},
- "hashtag_messages_select_policy": {
- "name": "hashtag_messages_select_policy",
+ "tilez_select_word_policy": {
+ "name": "tilez_select_word_policy",
"as": "PERMISSIVE",
"for": "SELECT",
"to": [
- "public"
+ "postgres_role"
]
},
- "hashtag_messages_update_policy": {
- "name": "hashtag_messages_update_policy",
+ "tilez_update_word_policy": {
+ "name": "tilez_update_word_policy",
"as": "PERMISSIVE",
"for": "UPDATE",
"to": [
- "authenticated"
+ "postgres_role"
]
}
},
- "isRLSEnabled": true
+ "checkConstraints": {},
+ "isRLSEnabled": false
},
- "public.user_follows": {
- "name": "user_follows",
+ "public.hashtag_messages": {
+ "name": "hashtag_messages",
"schema": "",
"columns": {
- "user_id": {
- "name": "user_id",
+ "hashtag_id": {
+ "name": "hashtag_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
- "following_user_id": {
- "name": "following_user_id",
+ "message_id": {
+ "name": "message_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
}
},
"indexes": {
- "user_follows_following_user_id_idx": {
- "name": "user_follows_following_user_id_idx",
+ "hashtag_messages_hashtag_id_idx": {
+ "name": "hashtag_messages_hashtag_id_idx",
"columns": [
{
- "expression": "following_user_id",
+ "expression": "hashtag_id",
+ "isExpression": false,
"asc": true,
- "nulls": "last",
- "opclass": "uuid_ops",
- "isExpression": false
+ "nulls": "last"
}
],
"isUnique": false,
@@ -1406,15 +1369,14 @@
"method": "btree",
"with": {}
},
- "user_follows_user_id_idx": {
- "name": "user_follows_user_id_idx",
+ "hashtag_messages_message_id_idx": {
+ "name": "hashtag_messages_message_id_idx",
"columns": [
{
- "expression": "user_id",
+ "expression": "message_id",
+ "isExpression": false,
"asc": true,
- "nulls": "last",
- "opclass": "uuid_ops",
- "isExpression": false
+ "nulls": "last"
}
],
"isUnique": false,
@@ -1424,13 +1386,12 @@
}
},
"foreignKeys": {
- "user_follows_following_user_id_users_id_fk": {
- "name": "user_follows_following_user_id_users_id_fk",
- "tableFrom": "user_follows",
- "tableTo": "users",
- "schemaTo": "public",
+ "hashtag_messages_hashtag_id_hashtags_id_fk": {
+ "name": "hashtag_messages_hashtag_id_hashtags_id_fk",
+ "tableFrom": "hashtag_messages",
+ "tableTo": "hashtags",
"columnsFrom": [
- "following_user_id"
+ "hashtag_id"
],
"columnsTo": [
"id"
@@ -1438,13 +1399,12 @@
"onDelete": "cascade",
"onUpdate": "cascade"
},
- "user_follows_user_id_users_id_fk": {
- "name": "user_follows_user_id_users_id_fk",
- "tableFrom": "user_follows",
- "tableTo": "users",
- "schemaTo": "public",
+ "hashtag_messages_message_id_messages_id_fk": {
+ "name": "hashtag_messages_message_id_messages_id_fk",
+ "tableFrom": "hashtag_messages",
+ "tableTo": "messages",
"columnsFrom": [
- "user_id"
+ "message_id"
],
"columnsTo": [
"id"
@@ -1454,119 +1414,133 @@
}
},
"compositePrimaryKeys": {
- "user_follows_pk": {
- "name": "user_follows_pk",
+ "hashtag_messages_pk": {
+ "name": "hashtag_messages_pk",
"columns": [
- "user_id",
- "following_user_id"
+ "hashtag_id",
+ "message_id"
]
}
},
"uniqueConstraints": {},
- "checkConstraints": {},
"policies": {
- "user_follows_delete_policy": {
- "name": "user_follows_delete_policy",
+ "hashtag_messages_delete_policy": {
+ "name": "hashtag_messages_delete_policy",
"as": "PERMISSIVE",
"for": "DELETE",
"to": [
- "authenticated"
+ "postgres_role"
],
- "using": "(user_id IN ( SELECT users.id\n FROM users\n WHERE (users.user_id = ( SELECT auth.uid() AS uid))))"
+ "using": "true"
},
- "user_follows_insert_policy": {
- "name": "user_follows_insert_policy",
+ "hashtag_messages_insert_policy": {
+ "name": "hashtag_messages_insert_policy",
"as": "PERMISSIVE",
"for": "INSERT",
"to": [
- "authenticated"
- ]
+ "postgres_role"
+ ],
+ "withCheck": "true"
},
- "user_follows_select_policy": {
- "name": "user_follows_select_policy",
+ "hashtag_messages_select_policy": {
+ "name": "hashtag_messages_select_policy",
"as": "PERMISSIVE",
"for": "SELECT",
"to": [
- "public"
- ]
+ "anon"
+ ],
+ "using": "true"
},
- "user_follows_update_policy": {
- "name": "user_follows_update_policy",
+ "hashtag_messages_update_policy": {
+ "name": "hashtag_messages_update_policy",
"as": "PERMISSIVE",
"for": "UPDATE",
"to": [
- "public"
- ]
+ "postgres_role"
+ ],
+ "using": "true"
}
},
- "isRLSEnabled": true
+ "checkConstraints": {},
+ "isRLSEnabled": false
},
- "public.items_required_research": {
- "name": "items_required_research",
+ "public.hashtags": {
+ "name": "hashtags",
"schema": "",
"columns": {
- "item_id": {
- "name": "item_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "required_id": {
- "name": "required_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "uuid_generate_v4()"
},
- "description": {
- "name": "description",
+ "hashtag": {
+ "name": "hashtag",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
- "indexes": {},
- "foreignKeys": {
- "items_required_research_item_id_shop_items_id_fk": {
- "name": "items_required_research_item_id_shop_items_id_fk",
- "tableFrom": "items_required_research",
- "tableTo": "shop_items",
- "schemaTo": "public",
- "columnsFrom": [
- "item_id"
+ "indexes": {
+ "hashtags_hashtag_idx": {
+ "name": "hashtags_hashtag_idx",
+ "columns": [
+ {
+ "expression": "hashtag",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
],
- "columnsTo": [
- "id"
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "hashtags_delete_policy": {
+ "name": "hashtags_delete_policy",
+ "as": "PERMISSIVE",
+ "for": "DELETE",
+ "to": [
+ "postgres_role"
],
- "onDelete": "no action",
- "onUpdate": "no action"
+ "using": "true"
},
- "items_required_research_required_id_research_id_fk": {
- "name": "items_required_research_required_id_research_id_fk",
- "tableFrom": "items_required_research",
- "tableTo": "research",
- "schemaTo": "public",
- "columnsFrom": [
- "required_id"
+ "hashtags_insert_policy": {
+ "name": "hashtags_insert_policy",
+ "as": "PERMISSIVE",
+ "for": "INSERT",
+ "to": [
+ "postgres_role"
],
- "columnsTo": [
- "id"
+ "withCheck": "true"
+ },
+ "hashtags_select_policy": {
+ "name": "hashtags_select_policy",
+ "as": "PERMISSIVE",
+ "for": "SELECT",
+ "to": [
+ "anon"
],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "items_required_research_item_id_required_id_pk": {
- "name": "items_required_research_item_id_required_id_pk",
- "columns": [
- "item_id",
- "required_id"
- ]
+ "using": "true"
+ },
+ "hashtags_update_policy": {
+ "name": "hashtags_update_policy",
+ "as": "PERMISSIVE",
+ "for": "UPDATE",
+ "to": [
+ "postgres_role"
+ ],
+ "using": "true"
}
},
- "uniqueConstraints": {},
"checkConstraints": {},
- "policies": {},
"isRLSEnabled": false
},
"public.likes": {
@@ -1595,13 +1569,12 @@
},
"indexes": {},
"foreignKeys": {
- "likes_message_id_messages_id_fk": {
- "name": "likes_message_id_messages_id_fk",
+ "likes_user_id_users_id_fk": {
+ "name": "likes_user_id_users_id_fk",
"tableFrom": "likes",
- "tableTo": "messages",
- "schemaTo": "public",
+ "tableTo": "users",
"columnsFrom": [
- "message_id"
+ "user_id"
],
"columnsTo": [
"id"
@@ -1609,13 +1582,12 @@
"onDelete": "cascade",
"onUpdate": "cascade"
},
- "likes_user_id_users_id_fk": {
- "name": "likes_user_id_users_id_fk",
+ "likes_message_id_messages_id_fk": {
+ "name": "likes_message_id_messages_id_fk",
"tableFrom": "likes",
- "tableTo": "users",
- "schemaTo": "public",
+ "tableTo": "messages",
"columnsFrom": [
- "user_id"
+ "message_id"
],
"columnsTo": [
"id"
@@ -1634,7 +1606,6 @@
}
},
"uniqueConstraints": {},
- "checkConstraints": {},
"policies": {
"likes_delete_policy": {
"name": "likes_delete_policy",
@@ -1643,7 +1614,7 @@
"to": [
"authenticated"
],
- "using": "(user_id IN ( SELECT users.id\n FROM users\n WHERE (users.user_id = ( SELECT auth.uid() AS uid))))"
+ "using": "(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))"
},
"likes_insert_policy": {
"name": "likes_insert_policy",
@@ -1651,383 +1622,468 @@
"for": "INSERT",
"to": [
"authenticated"
- ]
+ ],
+ "withCheck": "(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))"
},
"likes_select_policy": {
"name": "likes_select_policy",
"as": "PERMISSIVE",
"for": "SELECT",
"to": [
- "public"
- ]
+ "anon"
+ ],
+ "using": "true"
},
"likes_update_policy": {
"name": "likes_update_policy",
"as": "PERMISSIVE",
"for": "UPDATE",
"to": [
- "public"
- ]
+ "authenticated"
+ ],
+ "using": "(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))",
+ "withCheck": "(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))"
}
},
- "isRLSEnabled": true
+ "checkConstraints": {},
+ "isRLSEnabled": false
},
- "public.research_required_research": {
- "name": "research_required_research",
+ "public.messages": {
+ "name": "messages",
"schema": "",
"columns": {
- "research_id": {
- "name": "research_id",
- "type": "integer",
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "uuid_generate_v4()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
"primaryKey": false,
"notNull": true
},
- "required_id": {
- "name": "required_id",
- "type": "integer",
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "description": {
- "name": "description",
+ "message": {
+ "name": "message",
"type": "text",
"primaryKey": false,
"notNull": true
+ },
+ "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": false
+ }
+ },
+ "indexes": {
+ "messages_user_id_idx": {
+ "name": "messages_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_parent_id_idx": {
+ "name": "messages_parent_id_idx",
+ "columns": [
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
- "indexes": {},
"foreignKeys": {
- "research_required_research_required_id_research_id_fk": {
- "name": "research_required_research_required_id_research_id_fk",
- "tableFrom": "research_required_research",
- "tableTo": "research",
- "schemaTo": "public",
+ "messages_user_id_users_id_fk": {
+ "name": "messages_user_id_users_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "users",
"columnsFrom": [
- "required_id"
+ "user_id"
],
"columnsTo": [
"id"
],
- "onDelete": "no action",
- "onUpdate": "no action"
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
},
- "research_required_research_research_id_research_id_fk": {
- "name": "research_required_research_research_id_research_id_fk",
- "tableFrom": "research_required_research",
- "tableTo": "research",
- "schemaTo": "public",
+ "messages_parent_id_messages_id_fk": {
+ "name": "messages_parent_id_messages_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "messages",
"columnsFrom": [
- "research_id"
+ "parent_id"
],
"columnsTo": [
"id"
],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "research_required_research_research_id_required_id_pk": {
- "name": "research_required_research_research_id_required_id_pk",
- "columns": [
- "research_id",
- "required_id"
- ]
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
}
},
+ "compositePrimaryKeys": {},
"uniqueConstraints": {},
- "checkConstraints": {},
- "policies": {},
- "isRLSEnabled": false
- },
- "public.upgrade_required_research": {
- "name": "upgrade_required_research",
- "schema": "",
- "columns": {
- "upgrade_id": {
- "name": "upgrade_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "required_id": {
- "name": "required_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {
- "upgrade_required_research_required_id_research_id_fk": {
- "name": "upgrade_required_research_required_id_research_id_fk",
- "tableFrom": "upgrade_required_research",
- "tableTo": "research",
- "schemaTo": "public",
- "columnsFrom": [
- "required_id"
+ "policies": {
+ "messages_delete_policy": {
+ "name": "messages_delete_policy",
+ "as": "PERMISSIVE",
+ "for": "DELETE",
+ "to": [
+ "authenticated"
],
- "columnsTo": [
- "id"
+ "using": "\"messages\".\"user_id\" = (select auth.uid())"
+ },
+ "messages_insert_policy": {
+ "name": "messages_insert_policy",
+ "as": "PERMISSIVE",
+ "for": "INSERT",
+ "to": [
+ "authenticated"
],
- "onDelete": "no action",
- "onUpdate": "no action"
+ "withCheck": "\"messages\".\"user_id\" = (select auth.uid())"
},
- "upgrade_required_research_upgrade_id_upgrades_id_fk": {
- "name": "upgrade_required_research_upgrade_id_upgrades_id_fk",
- "tableFrom": "upgrade_required_research",
- "tableTo": "upgrades",
- "schemaTo": "public",
- "columnsFrom": [
- "upgrade_id"
+ "messages_select_policy": {
+ "name": "messages_select_policy",
+ "as": "PERMISSIVE",
+ "for": "SELECT",
+ "to": [
+ "anon"
],
- "columnsTo": [
- "id"
+ "using": "true"
+ },
+ "messages_update_policy": {
+ "name": "messages_update_policy",
+ "as": "PERMISSIVE",
+ "for": "UPDATE",
+ "to": [
+ "authenticated"
],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "upgrade_required_research_upgrade_id_research_id_pk": {
- "name": "upgrade_required_research_upgrade_id_research_id_pk",
- "columns": [
- "upgrade_id",
- "required_id"
- ]
+ "using": "\"messages\".\"user_id\" = (select auth.uid())",
+ "withCheck": "\"messages\".\"user_id\" = (select auth.uid())"
}
},
- "uniqueConstraints": {},
"checkConstraints": {},
- "policies": {},
"isRLSEnabled": false
},
- "public.items_required_items": {
- "name": "items_required_items",
+ "public.user_follows": {
+ "name": "user_follows",
"schema": "",
"columns": {
- "item_id": {
- "name": "item_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- },
- "required_id": {
- "name": "required_id",
- "type": "integer",
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
"primaryKey": false,
"notNull": true
},
- "quantity": {
- "name": "quantity",
- "type": "integer",
+ "following_user_id": {
+ "name": "following_user_id",
+ "type": "uuid",
"primaryKey": false,
"notNull": true
+ }
+ },
+ "indexes": {
+ "user_follows_user_id_idx": {
+ "name": "user_follows_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
},
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": true
+ "user_follows_following_user_id_idx": {
+ "name": "user_follows_following_user_id_idx",
+ "columns": [
+ {
+ "expression": "following_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
- "indexes": {},
"foreignKeys": {
- "items_required_items_item_id_shop_items_id_fk": {
- "name": "items_required_items_item_id_shop_items_id_fk",
- "tableFrom": "items_required_items",
- "tableTo": "shop_items",
- "schemaTo": "public",
+ "user_follows_user_id_users_id_fk": {
+ "name": "user_follows_user_id_users_id_fk",
+ "tableFrom": "user_follows",
+ "tableTo": "users",
"columnsFrom": [
- "item_id"
+ "user_id"
],
"columnsTo": [
"id"
],
- "onDelete": "no action",
- "onUpdate": "no action"
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
},
- "items_required_items_required_id_shop_items_id_fk": {
- "name": "items_required_items_required_id_shop_items_id_fk",
- "tableFrom": "items_required_items",
- "tableTo": "shop_items",
- "schemaTo": "public",
+ "user_follows_following_user_id_users_id_fk": {
+ "name": "user_follows_following_user_id_users_id_fk",
+ "tableFrom": "user_follows",
+ "tableTo": "users",
"columnsFrom": [
- "required_id"
+ "following_user_id"
],
"columnsTo": [
"id"
],
- "onDelete": "no action",
- "onUpdate": "no action"
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
}
},
"compositePrimaryKeys": {
- "items_required_items_item_id_required_id_pk": {
- "name": "items_required_items_item_id_required_id_pk",
+ "user_follows_pk": {
+ "name": "user_follows_pk",
"columns": [
- "item_id",
- "required_id"
+ "user_id",
+ "following_user_id"
]
}
},
"uniqueConstraints": {},
+ "policies": {
+ "user_follows_delete_policy": {
+ "name": "user_follows_delete_policy",
+ "as": "PERMISSIVE",
+ "for": "DELETE",
+ "to": [
+ "authenticated"
+ ],
+ "using": "(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))"
+ },
+ "user_follows_insert_policy": {
+ "name": "user_follows_insert_policy",
+ "as": "PERMISSIVE",
+ "for": "INSERT",
+ "to": [
+ "authenticated"
+ ],
+ "withCheck": "(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))"
+ },
+ "user_follows_select_policy": {
+ "name": "user_follows_select_policy",
+ "as": "PERMISSIVE",
+ "for": "SELECT",
+ "to": [
+ "anon"
+ ],
+ "using": "true"
+ },
+ "user_follows_update_policy": {
+ "name": "user_follows_update_policy",
+ "as": "PERMISSIVE",
+ "for": "UPDATE",
+ "to": [
+ "authenticated"
+ ],
+ "using": "(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))",
+ "withCheck": "(user_id IN ( SELECT users.id FROM users WHERE (users.user_id = ( SELECT auth.uid() AS uid))))"
+ }
+ },
"checkConstraints": {},
- "policies": {},
"isRLSEnabled": false
},
- "public.research_required_items": {
- "name": "research_required_items",
+ "public.users": {
+ "name": "users",
"schema": "",
"columns": {
- "research_id": {
- "name": "research_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "uuid_generate_v4()"
},
- "item_id": {
- "name": "item_id",
- "type": "integer",
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "quantity": {
- "name": "quantity",
- "type": "integer",
+ "username": {
+ "name": "username",
+ "type": "text",
"primaryKey": false,
"notNull": true
},
- "description": {
- "name": "description",
+ "email": {
+ "name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {
- "research_required_items_item_id_shop_items_id_fk": {
- "name": "research_required_items_item_id_shop_items_id_fk",
- "tableFrom": "research_required_items",
- "tableTo": "shop_items",
- "schemaTo": "public",
- "columnsFrom": [
- "item_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
},
- "research_required_items_research_id_research_id_fk": {
- "name": "research_required_items_research_id_research_id_fk",
- "tableFrom": "research_required_items",
- "tableTo": "research",
- "schemaTo": "public",
- "columnsFrom": [
- "research_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "research_required_items_research_id_item_id_pk": {
- "name": "research_required_items_research_id_item_id_pk",
- "columns": [
- "research_id",
- "item_id"
- ]
- }
- },
- "uniqueConstraints": {},
- "checkConstraints": {},
- "policies": {},
- "isRLSEnabled": false
- },
- "public.upgrade_required_items": {
- "name": "upgrade_required_items",
- "schema": "",
- "columns": {
- "upgrade_id": {
- "name": "upgrade_id",
- "type": "integer",
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": "now()"
},
- "item_id": {
- "name": "item_id",
- "type": "integer",
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "quantity": {
- "name": "quantity",
- "type": "integer",
+ "bio": {
+ "name": "bio",
+ "type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "description": {
- "name": "description",
+ "avatar": {
+ "name": "avatar",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
}
},
- "indexes": {},
- "foreignKeys": {
- "upgrade_required_items_item_id_shop_items_id_fk": {
- "name": "upgrade_required_items_item_id_shop_items_id_fk",
- "tableFrom": "upgrade_required_items",
- "tableTo": "shop_items",
- "schemaTo": "public",
- "columnsFrom": [
- "item_id"
+ "indexes": {
+ "users_username_idx": {
+ "name": "users_username_idx",
+ "columns": [
+ {
+ "expression": "username",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
],
- "columnsTo": [
- "id"
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_email_idx": {
+ "name": "users_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
],
- "onDelete": "no action",
- "onUpdate": "no action"
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
},
- "upgrade_required_items_upgrade_id_upgrades_id_fk": {
- "name": "upgrade_required_items_upgrade_id_upgrades_id_fk",
- "tableFrom": "upgrade_required_items",
- "tableTo": "upgrades",
- "schemaTo": "public",
+ "users_user_id_idx": {
+ "name": "users_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "users_user_id_users_id_fk": {
+ "name": "users_user_id_users_id_fk",
+ "tableFrom": "users",
+ "tableTo": "users",
+ "schemaTo": "auth",
"columnsFrom": [
- "upgrade_id"
+ "user_id"
],
"columnsTo": [
"id"
],
- "onDelete": "no action",
- "onUpdate": "no action"
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
}
},
- "compositePrimaryKeys": {
- "upgrade_required_items_upgrade_id_item_id_pk": {
- "name": "upgrade_required_items_upgrade_id_item_id_pk",
- "columns": [
- "upgrade_id",
- "item_id"
- ]
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "users_delete_policy": {
+ "name": "users_delete_policy",
+ "as": "PERMISSIVE",
+ "for": "DELETE",
+ "to": [
+ "authenticated"
+ ],
+ "using": "\"users\".\"user_id\" = (select auth.uid())"
+ },
+ "users_insert_policy": {
+ "name": "users_insert_policy",
+ "as": "PERMISSIVE",
+ "for": "INSERT",
+ "to": [
+ "authenticated"
+ ],
+ "withCheck": "\"users\".\"user_id\" = (select auth.uid())"
+ },
+ "users_select_policy": {
+ "name": "users_select_policy",
+ "as": "PERMISSIVE",
+ "for": "SELECT",
+ "to": [
+ "anon"
+ ],
+ "using": "true"
+ },
+ "users_update_policy": {
+ "name": "users_update_policy",
+ "as": "PERMISSIVE",
+ "for": "UPDATE",
+ "to": [
+ "authenticated"
+ ],
+ "using": "\"users\".\"user_id\" = (select auth.uid())",
+ "withCheck": "\"users\".\"user_id\" = (select auth.uid())"
}
},
- "uniqueConstraints": {},
"checkConstraints": {},
- "policies": {},
"isRLSEnabled": false
}
},
@@ -2038,40 +2094,8 @@
"policies": {},
"views": {},
"_meta": {
+ "columns": {},
"schemas": {},
- "tables": {},
- "columns": {}
- },
- "internal": {
- "tables": {
- "characters": {
- "columns": {
- "description": {
- "isArray": true,
- "dimensions": 1,
- "rawType": "text"
- }
- }
- },
- "gamestate": {
- "columns": {
- "researched": {
- "isArray": true,
- "dimensions": 1,
- "rawType": "integer"
- },
- "upgrades": {
- "isArray": true,
- "dimensions": 1,
- "rawType": "json"
- },
- "items": {
- "isArray": true,
- "dimensions": 1,
- "rawType": "json"
- }
- }
- }
- }
+ "tables": {}
}
}
\ No newline at end of file
diff --git a/src/db/migrations/meta/_journal.json b/src/db/migrations/meta/_journal.json
index df11d3c..3ad5471 100644
--- a/src/db/migrations/meta/_journal.json
+++ b/src/db/migrations/meta/_journal.json
@@ -5,8 +5,8 @@
{
"idx": 0,
"version": "7",
- "when": 1730308194751,
- "tag": "20241030170954_petite_whistler",
+ "when": 1737152320970,
+ "tag": "20250117221840_crazy_spitfire",
"breakpoints": true
}
]
diff --git a/src/db/migrations/relations.ts b/src/db/migrations/relations.ts
deleted file mode 100644
index b2e8324..0000000
--- a/src/db/migrations/relations.ts
+++ /dev/null
@@ -1,224 +0,0 @@
-import { relations } from "drizzle-orm/relations";
-import { cities, characters, elements, upgrades, levels, messages, users, usersInAuth, tilezGames, todos, shopItems, hashtags, hashtagMessages, userFollows, itemsRequiredResearch, research, likes, researchRequiredResearch, upgradeRequiredResearch, itemsRequiredItems, researchRequiredItems, upgradeRequiredItems } from "./schema";
-
-export const charactersRelations = relations(characters, ({one}) => ({
- city: one(cities, {
- fields: [characters.cityId],
- references: [cities.id]
- }),
- element: one(elements, {
- fields: [characters.elementId],
- references: [elements.id]
- }),
-}));
-
-export const citiesRelations = relations(cities, ({many}) => ({
- characters: many(characters),
-}));
-
-export const elementsRelations = relations(elements, ({many}) => ({
- characters: many(characters),
-}));
-
-export const levelsRelations = relations(levels, ({one}) => ({
- upgrade: one(upgrades, {
- fields: [levels.upgradeId],
- references: [upgrades.id]
- }),
-}));
-
-export const upgradesRelations = relations(upgrades, ({one, many}) => ({
- levels: many(levels),
- shopItem: one(shopItems, {
- fields: [upgrades.effectItemId],
- references: [shopItems.id]
- }),
- upgradeRequiredResearches: many(upgradeRequiredResearch),
- upgradeRequiredItems: many(upgradeRequiredItems),
-}));
-
-export const messagesRelations = relations(messages, ({one, many}) => ({
- message: one(messages, {
- fields: [messages.parentId],
- references: [messages.id],
- relationName: "messages_parentId_messages_id"
- }),
- messages: many(messages, {
- relationName: "messages_parentId_messages_id"
- }),
- user: one(users, {
- fields: [messages.userId],
- references: [users.id]
- }),
- hashtagMessages: many(hashtagMessages),
- likes: many(likes),
-}));
-
-export const usersRelations = relations(users, ({one, many}) => ({
- messages: many(messages),
- usersInAuth: one(usersInAuth, {
- fields: [users.userId],
- references: [usersInAuth.id]
- }),
- userFollows_followingUserId: many(userFollows, {
- relationName: "userFollows_followingUserId_users_id"
- }),
- userFollows_userId: many(userFollows, {
- relationName: "userFollows_userId_users_id"
- }),
- likes: many(likes),
-}));
-
-export const tilezGamesRelations = relations(tilezGames, ({one}) => ({
- usersInAuth: one(usersInAuth, {
- fields: [tilezGames.userId],
- references: [usersInAuth.id]
- }),
-}));
-
-export const usersInAuthRelations = relations(usersInAuth, ({many}) => ({
- tilezGames: many(tilezGames),
- todos: many(todos),
- users: many(users),
-}));
-
-export const todosRelations = relations(todos, ({one}) => ({
- usersInAuth: one(usersInAuth, {
- fields: [todos.userId],
- references: [usersInAuth.id]
- }),
-}));
-
-export const shopItemsRelations = relations(shopItems, ({many}) => ({
- upgrades: many(upgrades),
- itemsRequiredResearches: many(itemsRequiredResearch),
- itemsRequiredItems_itemId: many(itemsRequiredItems, {
- relationName: "itemsRequiredItems_itemId_shopItems_id"
- }),
- itemsRequiredItems_requiredId: many(itemsRequiredItems, {
- relationName: "itemsRequiredItems_requiredId_shopItems_id"
- }),
- researchRequiredItems: many(researchRequiredItems),
- upgradeRequiredItems: many(upgradeRequiredItems),
-}));
-
-export const hashtagMessagesRelations = relations(hashtagMessages, ({one}) => ({
- hashtag: one(hashtags, {
- fields: [hashtagMessages.hashtagId],
- references: [hashtags.id]
- }),
- message: one(messages, {
- fields: [hashtagMessages.messageId],
- references: [messages.id]
- }),
-}));
-
-export const hashtagsRelations = relations(hashtags, ({many}) => ({
- hashtagMessages: many(hashtagMessages),
-}));
-
-export const userFollowsRelations = relations(userFollows, ({one}) => ({
- user_followingUserId: one(users, {
- fields: [userFollows.followingUserId],
- references: [users.id],
- relationName: "userFollows_followingUserId_users_id"
- }),
- user_userId: one(users, {
- fields: [userFollows.userId],
- references: [users.id],
- relationName: "userFollows_userId_users_id"
- }),
-}));
-
-export const itemsRequiredResearchRelations = relations(itemsRequiredResearch, ({one}) => ({
- shopItem: one(shopItems, {
- fields: [itemsRequiredResearch.itemId],
- references: [shopItems.id]
- }),
- research: one(research, {
- fields: [itemsRequiredResearch.requiredId],
- references: [research.id]
- }),
-}));
-
-export const researchRelations = relations(research, ({many}) => ({
- itemsRequiredResearches: many(itemsRequiredResearch),
- researchRequiredResearches_requiredId: many(researchRequiredResearch, {
- relationName: "researchRequiredResearch_requiredId_research_id"
- }),
- researchRequiredResearches_researchId: many(researchRequiredResearch, {
- relationName: "researchRequiredResearch_researchId_research_id"
- }),
- upgradeRequiredResearches: many(upgradeRequiredResearch),
- researchRequiredItems: many(researchRequiredItems),
-}));
-
-export const likesRelations = relations(likes, ({one}) => ({
- message: one(messages, {
- fields: [likes.messageId],
- references: [messages.id]
- }),
- user: one(users, {
- fields: [likes.userId],
- references: [users.id]
- }),
-}));
-
-export const researchRequiredResearchRelations = relations(researchRequiredResearch, ({one}) => ({
- research_requiredId: one(research, {
- fields: [researchRequiredResearch.requiredId],
- references: [research.id],
- relationName: "researchRequiredResearch_requiredId_research_id"
- }),
- research_researchId: one(research, {
- fields: [researchRequiredResearch.researchId],
- references: [research.id],
- relationName: "researchRequiredResearch_researchId_research_id"
- }),
-}));
-
-export const upgradeRequiredResearchRelations = relations(upgradeRequiredResearch, ({one}) => ({
- research: one(research, {
- fields: [upgradeRequiredResearch.requiredId],
- references: [research.id]
- }),
- upgrade: one(upgrades, {
- fields: [upgradeRequiredResearch.upgradeId],
- references: [upgrades.id]
- }),
-}));
-
-export const itemsRequiredItemsRelations = relations(itemsRequiredItems, ({one}) => ({
- shopItem_itemId: one(shopItems, {
- fields: [itemsRequiredItems.itemId],
- references: [shopItems.id],
- relationName: "itemsRequiredItems_itemId_shopItems_id"
- }),
- shopItem_requiredId: one(shopItems, {
- fields: [itemsRequiredItems.requiredId],
- references: [shopItems.id],
- relationName: "itemsRequiredItems_requiredId_shopItems_id"
- }),
-}));
-
-export const researchRequiredItemsRelations = relations(researchRequiredItems, ({one}) => ({
- shopItem: one(shopItems, {
- fields: [researchRequiredItems.itemId],
- references: [shopItems.id]
- }),
- research: one(research, {
- fields: [researchRequiredItems.researchId],
- references: [research.id]
- }),
-}));
-
-export const upgradeRequiredItemsRelations = relations(upgradeRequiredItems, ({one}) => ({
- shopItem: one(shopItems, {
- fields: [upgradeRequiredItems.itemId],
- references: [shopItems.id]
- }),
- upgrade: one(upgrades, {
- fields: [upgradeRequiredItems.upgradeId],
- references: [upgrades.id]
- }),
-}));
\ No newline at end of file
diff --git a/src/db/migrations/schema.ts b/src/db/migrations/schema.ts
deleted file mode 100644
index 104f9e5..0000000
--- a/src/db/migrations/schema.ts
+++ /dev/null
@@ -1,448 +0,0 @@
-import { pgTable, foreignKey, unique, integer, text, bigint, real, json, index, pgPolicy, uuid, timestamp, boolean, uniqueIndex, char, primaryKey } from "drizzle-orm/pg-core"
-import { sql } from "drizzle-orm"
-import {
- authenticatedRole,
- authUid,
- authUsers,
- realtimeMessages,
- realtimeTopic,
- supabaseAuthAdminRole,
- } from "drizzle-orm/supabase";
-
- export const usersInAuth = authUsers
-
-export const characters = pgTable("characters", {
- id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "characters_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
- name: text().notNull(),
- description: text().array().notNull(),
- elementId: integer("element_id").notNull(),
- cityId: integer("city_id").notNull(),
-}, (table) => {
- return {
- charactersCityIdCitiesIdFk: foreignKey({
- columns: [table.cityId],
- foreignColumns: [cities.id],
- name: "characters_city_id_cities_id_fk"
- }),
- charactersElementIdElementsIdFk: foreignKey({
- columns: [table.elementId],
- foreignColumns: [elements.id],
- name: "characters_element_id_elements_id_fk"
- }),
- charactersNameUnique: unique("characters_name_unique").on(table.name),
- }
-});
-
-export const cities = pgTable("cities", {
- id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "cities_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
- name: text().notNull(),
-}, (table) => {
- return {
- citiesNameUnique: unique("cities_name_unique").on(table.name),
- }
-});
-
-export const elements = pgTable("elements", {
- id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "elements_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
- name: text().notNull(),
- colour: text().notNull(),
-}, (table) => {
- return {
- elementsNameUnique: unique("elements_name_unique").on(table.name),
- elementsColourUnique: unique("elements_colour_unique").on(table.colour),
- }
-});
-
-export const gamestate = pgTable("gamestate", {
- id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "gamestats_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
- playername: text().notNull(),
- theme: text().notNull(),
- // You can use { mode: "bigint" } if numbers are exceeding js number limitations
- currentscore: bigint({ mode: "number" }).notNull(),
- // You can use { mode: "bigint" } if numbers are exceeding js number limitations
- totalclicks: bigint({ mode: "number" }).notNull(),
- // You can use { mode: "bigint" } if numbers are exceeding js number limitations
- totalspent: bigint({ mode: "number" }).notNull(),
- currentaveragecps: real().notNull(),
- averageclickvalue: real().notNull(),
- researched: integer().array().notNull(),
- upgrades: json().array().notNull(),
- items: json().array().notNull(),
-});
-
-export const hashtags = pgTable("hashtags", {
- id: uuid().default(sql`uuid_generate_v4()`).primaryKey().notNull(),
- hashtag: text().notNull(),
-}, (table) => {
- return {
- hashtagIdx: index("hashtags_hashtag_idx").using("btree", table.hashtag.asc().nullsLast()),
- hashtagsDeletePolicy: pgPolicy("hashtags_delete_policy", { as: "permissive", for: "delete", to: ["authenticated"], using: sql`true` }),
- hashtagsInsertPolicy: pgPolicy("hashtags_insert_policy", { as: "permissive", for: "insert", to: ["authenticated"] }),
- hashtagsSelectPolicy: pgPolicy("hashtags_select_policy", { as: "permissive", for: "select", to: ["public"] }),
- hashtagsUpdatePolicy: pgPolicy("hashtags_update_policy", { as: "permissive", for: "update", to: ["authenticated"] }),
- }
-});
-
-export const levels = pgTable("levels", {
- id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "levels_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
- level: integer().notNull(),
- upgradeId: integer("upgrade_id").notNull(),
- cost: integer().notNull(),
- baseValue: real().notNull(),
- critChance: real().notNull(),
- critDamage: real().notNull(),
-}, (table) => {
- return {
- levelsUpgradeIdUpgradesIdFk: foreignKey({
- columns: [table.upgradeId],
- foreignColumns: [upgrades.id],
- name: "levels_upgrade_id_upgrades_id_fk"
- }),
- }
-});
-
-export const messages = pgTable("messages", {
- id: uuid().default(sql`uuid_generate_v4()`).primaryKey().notNull(),
- userId: uuid("user_id").notNull(),
- parentId: uuid("parent_id"),
- message: text().notNull(),
- createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
- updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }),
-}, (table) => {
- return {
- parentIdIdx: index("messages_parent_id_idx").using("btree", table.parentId.asc().nullsLast()),
- userIdIdx: index("messages_user_id_idx").using("btree", table.userId.asc().nullsLast()),
- messagesParentIdMessagesIdFk: foreignKey({
- columns: [table.parentId],
- foreignColumns: [table.id],
- name: "messages_parent_id_messages_id_fk"
- }).onUpdate("cascade").onDelete("cascade"),
- messagesUserIdUsersIdFk: foreignKey({
- columns: [table.userId],
- foreignColumns: [users.id],
- name: "messages_user_id_users_id_fk"
- }).onUpdate("cascade").onDelete("cascade"),
- messagesDeletePolicy: pgPolicy("messages_delete_policy", { as: "permissive", for: "delete", to: ["authenticated"], using: sql`(user_id IN ( SELECT users.id
- FROM users
- WHERE (users.user_id = ( SELECT auth.uid() AS uid))))` }),
- messagesInsertPolicy: pgPolicy("messages_insert_policy", { as: "permissive", for: "insert", to: ["authenticated"] }),
- messagesSelectPolicy: pgPolicy("messages_select_policy", { as: "permissive", for: "select", to: ["public"] }),
- messagesUpdatePolicy: pgPolicy("messages_update_policy", { as: "permissive", for: "update", to: ["public"] }),
- }
-});
-
-export const research = pgTable("research", {
- id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "research_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
- name: text().notNull(),
- description: text().notNull(),
- cost: integer().notNull(),
-});
-
-export const shopItems = pgTable("shop_items", {
- id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "shop_items_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
- name: text().notNull(),
- cost: integer().notNull(),
- maxQty: integer().notNull(),
- multiplier: real().notNull(),
- baseValue: real().notNull(),
- critChance: real().notNull(),
- critDamage: real().notNull(),
-});
-
-export const tilezGames = pgTable("tilez_games", {
- id: uuid().default(sql`uuid_generate_v4()`).primaryKey().notNull(),
- gameId: text("game_id").notNull(),
- userId: uuid("user_id").notNull(),
- gameStart: timestamp("game_start", { mode: 'string' }),
- gameEnd: timestamp("game_end", { mode: 'string' }).defaultNow(),
- numMoves: integer("num_moves").default(0),
- completed: boolean().default(false),
-}, (table) => {
- return {
- tilezGameIdIdx: index("tilez_game_id_idx").using("btree", table.gameId.asc().nullsLast()),
- tilezGameUserIdIdx: index("tilez_game_user_id_idx").using("btree", table.userId.asc().nullsLast()),
- tilezGamesUserIdUsersIdFk: foreignKey({
- columns: [table.userId],
- foreignColumns: [users.id],
- name: "tilez_games_user_id_users_id_fk"
- }).onUpdate("cascade").onDelete("cascade"),
- tilezDeletePolicy: pgPolicy("tilez_delete_policy", { as: "permissive", for: "delete", to: ["authenticated"], using: sql`(( SELECT auth.uid() AS uid) = user_id)` }),
- tilezInsertPolicy: pgPolicy("tilez_insert_policy", { as: "permissive", for: "insert", to: ["authenticated"] }),
- tilezSelectPolicy: pgPolicy("tilez_select_policy", { as: "permissive", for: "select", to: ["public"] }),
- tilezUpdatePolicy: pgPolicy("tilez_update_policy", { as: "permissive", for: "update", to: ["public"] }),
- }
-});
-
-export const tilezWords = pgTable("tilez_words", {
- id: uuid().default(sql`uuid_generate_v4()`).primaryKey().notNull(),
- word: char({ length: 6 }).notNull(),
- definition: text().notNull(),
- lastChecked: timestamp("last_checked", { mode: 'string' }).notNull(),
-}, (table) => {
- return {
- tilezWordWordIdx: uniqueIndex("tilez_word_word_idx").using("btree", table.word.asc().nullsLast()),
- }
-});
-
-export const todos = pgTable("todos", {
- id: uuid().default(sql`uuid_generate_v4()`).primaryKey().notNull(),
- title: text().notNull(),
- completed: boolean().default(false).notNull(),
- userId: uuid("user_id").notNull(),
- createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
-}, (table) => {
- return {
- userIdIdx: index("todos_user_id_idx").using("btree", table.userId.asc().nullsLast()),
- todosUserIdUsersIdFk: foreignKey({
- columns: [table.userId],
- foreignColumns: [users.id],
- name: "todos_user_id_users_id_fk"
- }),
- todosDeletePolicy: pgPolicy("todos_delete_policy", { as: "permissive", for: "delete", to: ["authenticated"], using: sql`(( SELECT auth.uid() AS uid) = user_id)` }),
- todosInsertPolicy: pgPolicy("todos_insert_policy", { as: "permissive", for: "insert", to: ["authenticated"] }),
- todosSelectPolicy: pgPolicy("todos_select_policy", { as: "permissive", for: "select", to: ["public"] }),
- todosUpdatePolicy: pgPolicy("todos_update_policy", { as: "permissive", for: "update", to: ["public"] }),
- }
-});
-
-export const upgrades = pgTable("upgrades", {
- id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "upgrades_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
- name: text().notNull(),
- description: text().notNull(),
- effectItemId: integer().notNull(),
-}, (table) => {
- return {
- upgradesEffectItemIdShopItemsIdFk: foreignKey({
- columns: [table.effectItemId],
- foreignColumns: [shopItems.id],
- name: "upgrades_effectItemId_shop_items_id_fk"
- }),
- }
-});
-
-export const users = pgTable("users", {
- id: uuid().default(sql`uuid_generate_v4()`).primaryKey().notNull(),
- userId: uuid("user_id"),
- username: text().notNull(),
- email: text().notNull(),
- createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
- updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }),
- bio: text(),
- avatar: text(),
-}, (table) => {
- return {
- emailIdx: index("users_email_idx").using("btree", table.email.asc().nullsLast()),
- userIdIdx: index("users_user_id_idx").using("btree", table.userId.asc().nullsLast()),
- usernameIdx: index("users_username_idx").using("btree", table.username.asc().nullsLast()),
- usersUserIdUsersIdFk: foreignKey({
- columns: [table.userId],
- foreignColumns: [table.id],
- name: "users_user_id_users_id_fk"
- }).onUpdate("cascade").onDelete("cascade"),
- usersDeletePolicy: pgPolicy("users_delete_policy", { as: "permissive", for: "delete", to: ["authenticated"], using: sql`(( SELECT auth.uid() AS uid) = user_id)` }),
- usersInsertPolicy: pgPolicy("users_insert_policy", { as: "permissive", for: "insert", to: ["authenticated"] }),
- usersSelectPolicy: pgPolicy("users_select_policy", { as: "permissive", for: "select", to: ["public"] }),
- usersUpdatePolicy: pgPolicy("users_update_policy", { as: "permissive", for: "update", to: ["public"] }),
- }
-});
-
-export const hashtagMessages = pgTable("hashtag_messages", {
- hashtagId: uuid("hashtag_id").notNull(),
- messageId: uuid("message_id").notNull(),
-}, (table) => {
- return {
- hashtagIdIdx: index("hashtag_messages_hashtag_id_idx").using("btree", table.hashtagId.asc().nullsLast()),
- messageIdIdx: index("hashtag_messages_message_id_idx").using("btree", table.messageId.asc().nullsLast()),
- hashtagMessagesHashtagIdHashtagsIdFk: foreignKey({
- columns: [table.hashtagId],
- foreignColumns: [hashtags.id],
- name: "hashtag_messages_hashtag_id_hashtags_id_fk"
- }).onUpdate("cascade").onDelete("restrict"),
- hashtagMessagesMessageIdMessagesIdFk: foreignKey({
- columns: [table.messageId],
- foreignColumns: [messages.id],
- name: "hashtag_messages_message_id_messages_id_fk"
- }).onUpdate("cascade").onDelete("cascade"),
- hashtagMessagesPk: primaryKey({ columns: [table.hashtagId, table.messageId], name: "hashtag_messages_pk"}),
- hashtagMessagesDeletePolicy: pgPolicy("hashtag_messages_delete_policy", { as: "permissive", for: "delete", to: ["authenticated"], using: sql`true` }),
- hashtagMessagesInsertPolicy: pgPolicy("hashtag_messages_insert_policy", { as: "permissive", for: "insert", to: ["authenticated"] }),
- hashtagMessagesSelectPolicy: pgPolicy("hashtag_messages_select_policy", { as: "permissive", for: "select", to: ["public"] }),
- hashtagMessagesUpdatePolicy: pgPolicy("hashtag_messages_update_policy", { as: "permissive", for: "update", to: ["authenticated"] }),
- }
-});
-
-export const userFollows = pgTable("user_follows", {
- userId: uuid("user_id").notNull(),
- followingUserId: uuid("following_user_id").notNull(),
-}, (table) => {
- return {
- followingUserIdIdx: index("user_follows_following_user_id_idx").using("btree", table.followingUserId.asc().nullsLast()),
- userIdIdx: index("user_follows_user_id_idx").using("btree", table.userId.asc().nullsLast()),
- userFollowsFollowingUserIdUsersIdFk: foreignKey({
- columns: [table.followingUserId],
- foreignColumns: [users.id],
- name: "user_follows_following_user_id_users_id_fk"
- }).onUpdate("cascade").onDelete("cascade"),
- userFollowsUserIdUsersIdFk: foreignKey({
- columns: [table.userId],
- foreignColumns: [users.id],
- name: "user_follows_user_id_users_id_fk"
- }).onUpdate("cascade").onDelete("cascade"),
- userFollowsPk: primaryKey({ columns: [table.userId, table.followingUserId], name: "user_follows_pk"}),
- userFollowsDeletePolicy: pgPolicy("user_follows_delete_policy", { as: "permissive", for: "delete", to: ["authenticated"], using: sql`(user_id IN ( SELECT users.id
- FROM users
- WHERE (users.user_id = ( SELECT auth.uid() AS uid))))` }),
- userFollowsInsertPolicy: pgPolicy("user_follows_insert_policy", { as: "permissive", for: "insert", to: ["authenticated"] }),
- userFollowsSelectPolicy: pgPolicy("user_follows_select_policy", { as: "permissive", for: "select", to: ["public"] }),
- userFollowsUpdatePolicy: pgPolicy("user_follows_update_policy", { as: "permissive", for: "update", to: ["public"] }),
- }
-});
-
-export const itemsRequiredResearch = pgTable("items_required_research", {
- itemId: integer("item_id").notNull(),
- requiredId: integer("required_id").notNull(),
- description: text().notNull(),
-}, (table) => {
- return {
- itemsRequiredResearchItemIdShopItemsIdFk: foreignKey({
- columns: [table.itemId],
- foreignColumns: [shopItems.id],
- name: "items_required_research_item_id_shop_items_id_fk"
- }),
- itemsRequiredResearchRequiredIdResearchIdFk: foreignKey({
- columns: [table.requiredId],
- foreignColumns: [research.id],
- name: "items_required_research_required_id_research_id_fk"
- }),
- itemsRequiredResearchItemIdRequiredIdPk: primaryKey({ columns: [table.itemId, table.requiredId], name: "items_required_research_item_id_required_id_pk"}),
- }
-});
-
-export const likes = pgTable("likes", {
- userId: uuid("user_id").notNull(),
- messageId: uuid("message_id").notNull(),
- like: integer().default(0).notNull(),
-}, (table) => {
- return {
- likesMessageIdMessagesIdFk: foreignKey({
- columns: [table.messageId],
- foreignColumns: [messages.id],
- name: "likes_message_id_messages_id_fk"
- }).onUpdate("cascade").onDelete("cascade"),
- likesUserIdUsersIdFk: foreignKey({
- columns: [table.userId],
- foreignColumns: [users.id],
- name: "likes_user_id_users_id_fk"
- }).onUpdate("cascade").onDelete("cascade"),
- likesPk: primaryKey({ columns: [table.userId, table.messageId], name: "likes_pk"}),
- likesDeletePolicy: pgPolicy("likes_delete_policy", { as: "permissive", for: "delete", to: ["authenticated"], using: sql`(user_id IN ( SELECT users.id
- FROM users
- WHERE (users.user_id = ( SELECT auth.uid() AS uid))))` }),
- likesInsertPolicy: pgPolicy("likes_insert_policy", { as: "permissive", for: "insert", to: ["authenticated"] }),
- likesSelectPolicy: pgPolicy("likes_select_policy", { as: "permissive", for: "select", to: ["public"] }),
- likesUpdatePolicy: pgPolicy("likes_update_policy", { as: "permissive", for: "update", to: ["public"] }),
- }
-});
-
-export const researchRequiredResearch = pgTable("research_required_research", {
- researchId: integer("research_id").notNull(),
- requiredId: integer("required_id").notNull(),
- description: text().notNull(),
-}, (table) => {
- return {
- researchRequiredResearchRequiredIdResearchIdFk: foreignKey({
- columns: [table.requiredId],
- foreignColumns: [research.id],
- name: "research_required_research_required_id_research_id_fk"
- }),
- researchRequiredResearchResearchIdResearchIdFk: foreignKey({
- columns: [table.researchId],
- foreignColumns: [research.id],
- name: "research_required_research_research_id_research_id_fk"
- }),
- researchRequiredResearchResearchIdRequiredIdPk: primaryKey({ columns: [table.researchId, table.requiredId], name: "research_required_research_research_id_required_id_pk"}),
- }
-});
-
-export const upgradeRequiredResearch = pgTable("upgrade_required_research", {
- upgradeId: integer("upgrade_id").notNull(),
- requiredId: integer("required_id").notNull(),
- description: text().notNull(),
-}, (table) => {
- return {
- upgradeRequiredResearchRequiredIdResearchIdFk: foreignKey({
- columns: [table.requiredId],
- foreignColumns: [research.id],
- name: "upgrade_required_research_required_id_research_id_fk"
- }),
- upgradeRequiredResearchUpgradeIdUpgradesIdFk: foreignKey({
- columns: [table.upgradeId],
- foreignColumns: [upgrades.id],
- name: "upgrade_required_research_upgrade_id_upgrades_id_fk"
- }),
- upgradeRequiredResearchUpgradeIdResearchIdPk: primaryKey({ columns: [table.upgradeId, table.requiredId], name: "upgrade_required_research_upgrade_id_research_id_pk"}),
- }
-});
-
-export const itemsRequiredItems = pgTable("items_required_items", {
- itemId: integer("item_id").notNull(),
- requiredId: integer("required_id").notNull(),
- quantity: integer().notNull(),
- description: text().notNull(),
-}, (table) => {
- return {
- itemsRequiredItemsItemIdShopItemsIdFk: foreignKey({
- columns: [table.itemId],
- foreignColumns: [shopItems.id],
- name: "items_required_items_item_id_shop_items_id_fk"
- }),
- itemsRequiredItemsRequiredIdShopItemsIdFk: foreignKey({
- columns: [table.requiredId],
- foreignColumns: [shopItems.id],
- name: "items_required_items_required_id_shop_items_id_fk"
- }),
- itemsRequiredItemsItemIdRequiredIdPk: primaryKey({ columns: [table.itemId, table.requiredId], name: "items_required_items_item_id_required_id_pk"}),
- }
-});
-
-export const researchRequiredItems = pgTable("research_required_items", {
- researchId: integer("research_id").notNull(),
- itemId: integer("item_id").notNull(),
- quantity: integer().notNull(),
- description: text().notNull(),
-}, (table) => {
- return {
- researchRequiredItemsItemIdShopItemsIdFk: foreignKey({
- columns: [table.itemId],
- foreignColumns: [shopItems.id],
- name: "research_required_items_item_id_shop_items_id_fk"
- }),
- researchRequiredItemsResearchIdResearchIdFk: foreignKey({
- columns: [table.researchId],
- foreignColumns: [research.id],
- name: "research_required_items_research_id_research_id_fk"
- }),
- researchRequiredItemsResearchIdItemIdPk: primaryKey({ columns: [table.researchId, table.itemId], name: "research_required_items_research_id_item_id_pk"}),
- }
-});
-
-export const upgradeRequiredItems = pgTable("upgrade_required_items", {
- upgradeId: integer("upgrade_id").notNull(),
- itemId: integer("item_id").notNull(),
- quantity: integer().notNull(),
- description: text().notNull(),
-}, (table) => {
- return {
- upgradeRequiredItemsItemIdShopItemsIdFk: foreignKey({
- columns: [table.itemId],
- foreignColumns: [shopItems.id],
- name: "upgrade_required_items_item_id_shop_items_id_fk"
- }),
- upgradeRequiredItemsUpgradeIdUpgradesIdFk: foreignKey({
- columns: [table.upgradeId],
- foreignColumns: [upgrades.id],
- name: "upgrade_required_items_upgrade_id_upgrades_id_fk"
- }),
- upgradeRequiredItemsUpgradeIdItemIdPk: primaryKey({ columns: [table.upgradeId, table.itemId], name: "upgrade_required_items_upgrade_id_item_id_pk"}),
- }
-});
diff --git a/src/db/seed/asteroid-seed.ts b/src/db/seed/asteroid-seed.ts
index fb65501..ba256e9 100755
--- a/src/db/seed/asteroid-seed.ts
+++ b/src/db/seed/asteroid-seed.ts
@@ -61,7 +61,7 @@ export const asteroidSeed = async (db: Transaction) => {
.values(
asteroidz.upgrades.map((u) => ({
...u,
- effectItemId: newShopItems.find((i) => i.name === u.name)?.id!,
+ effectItemId: newShopItems.find((i) => i.name === u.effectItem)?.id!,
})),
)
.returning();
diff --git a/src/db/seed/seed.ts b/src/db/seed/seed.ts
index 84c5419..4ee6d49 100755
--- a/src/db/seed/seed.ts
+++ b/src/db/seed/seed.ts
@@ -45,8 +45,8 @@ const main = async () => {
process.exit(0);
}
console.log("Seeding database...");
- // await seedGenshin();
- // await seedAsteroid();
+ await seedGenshin();
+ await seedAsteroid();
await seedForum();
console.log("Seeding complete");
process.exit(0);
diff --git a/src/db/tilez/db.ts b/src/db/tilez/db.ts
index f984740..13fef0d 100644
--- a/src/db/tilez/db.ts
+++ b/src/db/tilez/db.ts
@@ -42,7 +42,7 @@ export function dbClient(
token.sub ?? "",
)}', TRUE);
-- set local role
- set local role ${sql.raw(token.role ?? "anon")};
+ set local role ${sql.raw(token.aud?.toString() ?? "anon")};
`);
return await transaction(tx);
} finally {
diff --git a/src/db/todos/db.ts b/src/db/todos/db.ts
index e0403ed..3dd3281 100644
--- a/src/db/todos/db.ts
+++ b/src/db/todos/db.ts
@@ -17,15 +17,16 @@ const db = drizzle({
}),
schema,
});
-export function dbClient<
- Token extends SupabaseToken = SupabaseToken,
->(token: Token) {
+export function dbClient(
+ token: Token,
+) {
return {
db,
rls: (async (transaction, ...rest) => {
- return await db.transaction(async (tx) => {
- try {
- await tx.execute(sql`
+ return await db.transaction(
+ async (tx) => {
+ try {
+ await tx.execute(sql`
-- auth.jwt()
select set_config('request.jwt.claims', '${sql.raw(
JSON.stringify(token),
@@ -35,18 +36,20 @@ export function dbClient<
token.sub ?? "",
)}', TRUE);
-- set local role
- set local role ${sql.raw(token.role ?? "anon")};
+ set local role ${sql.raw(token.aud?.toString() ?? "anon")};
`);
- return await transaction(tx);
- } finally {
- await tx.execute(sql`
+ return await transaction(tx);
+ } finally {
+ await tx.execute(sql`
-- reset
select set_config('request.jwt.claims', NULL, TRUE);
select set_config('request.jwt.claim.sub', NULL, TRUE);
reset role;
`);
- }
- }, ...rest);
+ }
+ },
+ ...rest,
+ );
}) as typeof db.transaction,
- }
+ };
}
diff --git a/src/middleware.ts b/src/middleware.ts
index 0e48e29..1769a93 100755
--- a/src/middleware.ts
+++ b/src/middleware.ts
@@ -2,9 +2,42 @@ import { NextResponse, type NextRequest } from "next/server";
import { getUser, isJWTValid, refreshToken } from "./lib/auth";
export async function middleware(request: NextRequest) {
- let newResponse = NextResponse.next({
- request,
+ const isDev = process.env.NODE_ENV === "development";
+ const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
+ const cspHeader = `
+ default-src 'self';
+ script-src 'self' 'nonce-${nonce}' 'strict-dynamic';
+ style-src 'self' 'unsafe-inline';
+ img-src 'self' blob: data: https://avatars.githubusercontent.com https://\*.googleusercontent.com;
+ font-src 'self';
+ object-src 'none';
+ base-uri 'self';
+ form-action 'self';
+ frame-ancestors 'none';
+ upgrade-insecure-requests;
+`;
+ // Replace newline characters and spaces
+ const contentSecurityPolicyHeaderValue = cspHeader
+ .replace(/\s{2,}/g, " ")
+ .trim();
+
+ const requestHeaders = new Headers(request.headers);
+ requestHeaders.set("x-nonce", nonce);
+
+ requestHeaders.set(
+ "Content-Security-Policy",
+ contentSecurityPolicyHeaderValue,
+ );
+ const newResponse = NextResponse.next({
+ request: {
+ headers: requestHeaders,
+ },
});
+ newResponse.headers.set(
+ "Content-Security-Policy",
+ contentSecurityPolicyHeaderValue,
+ );
+
const cookies = request.cookies;
const access_token = cookies.get("access_token")?.value;
const refresh_token = cookies.get("refresh_token")?.value;
@@ -21,9 +54,6 @@ export async function middleware(request: NextRequest) {
if (token) {
cookies.set("access_token", JSON.stringify(token.access_token));
cookies.set("refresh_token", JSON.stringify(token.refresh_token));
- newResponse = NextResponse.next({
- request,
- });
newResponse.cookies.set("access_token", token.access_token, {
httpOnly: true,
sameSite: "lax",
@@ -42,10 +72,14 @@ export async function middleware(request: NextRequest) {
cookies.delete("refresh_token");
const url = request.nextUrl.clone();
url.pathname = "/";
- newResponse = NextResponse.redirect(url);
- newResponse.cookies.delete("access_token");
- newResponse.cookies.delete("refresh_token");
- return newResponse;
+ const newRedirect = NextResponse.redirect(url);
+ newRedirect.cookies.delete("access_token");
+ newRedirect.cookies.delete("refresh_token");
+ newRedirect.headers.set(
+ "Content-Security-Policy",
+ contentSecurityPolicyHeaderValue,
+ );
+ return newRedirect;
}
return newResponse;
}
@@ -54,11 +88,17 @@ export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
+ * - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
- * Feel free to modify this pattern to include more paths.
*/
- "/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
+ {
+ source: "/((?!api|_next/static|_next/image|favicon.ico).*)",
+ missing: [
+ { type: "header", key: "next-router-prefetch" },
+ { type: "header", key: "purpose", value: "prefetch" },
+ ],
+ },
],
};