Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Add organization

Bill Yang28eb6fe4594c
diff --git a/client/src/components/SiteCard.tsx b/client/src/components/SiteCard.tsx
index 5ac8c7be3..07b134910 100644
--- a/client/src/components/SiteCard.tsx
+++ b/client/src/components/SiteCard.tsx
@@ -1,11 +1,10 @@
import { useGetOverview, useGetOverviewBucketed } from "@/hooks/api";
+import { ArrowRight } from "lucide-react";
import Link from "next/link";
import { SiteSessionChart } from "./SiteSessionChart";
import { SiteSettings } from "./SiteSettings/SiteSettings";
import { Button } from "./ui/button";
import { Skeleton } from "./ui/skeleton";
-import { ArrowRight } from "lucide-react";
-import { cn } from "@/lib/utils";
interface SiteCardProps {
siteId: number;
diff --git a/server/drizzle.config.ts b/server/drizzle.config.ts
index bf2369a71..cae7c451c 100644
--- a/server/drizzle.config.ts
+++ b/server/drizzle.config.ts
@@ -6,7 +6,8 @@ export default defineConfig({
out: "./drizzle",
dialect: "postgresql",
dbCredentials: {
- host: "postgres",
+ host: "5.78.110.218",
+ // host: "postgres",
port: 5432,
database: "analytics",
user: "frog",
diff --git a/server/drizzle/0000_gorgeous_shriek.sql b/server/drizzle/0000_gorgeous_shriek.sql
deleted file mode 100644
index 9c5f18155..000000000
--- a/server/drizzle/0000_gorgeous_shriek.sql
+++ /dev/null
@@ -1,109 +0,0 @@
-CREATE TABLE "account" (
- "id" text PRIMARY KEY NOT NULL,
- "accountId" text NOT NULL,
- "providerId" text NOT NULL,
- "userId" text NOT NULL,
- "accessToken" text,
- "refreshToken" text,
- "idToken" text,
- "accessTokenExpiresAt" timestamp,
- "refreshTokenExpiresAt" timestamp,
- "scope" text,
- "password" text,
- "createdAt" timestamp NOT NULL,
- "updatedAt" timestamp NOT NULL
-);
---> statement-breakpoint
-CREATE TABLE "active_sessions" (
- "session_id" text PRIMARY KEY NOT NULL,
- "site_id" integer,
- "user_id" text,
- "hostname" text,
- "start_time" timestamp DEFAULT now(),
- "last_activity" timestamp DEFAULT now(),
- "pageviews" integer DEFAULT 0,
- "entry_page" text,
- "exit_page" text,
- "device_type" text,
- "screen_width" integer,
- "screen_height" integer,
- "browser" text,
- "operating_system" text,
- "language" text,
- "referrer" text
-);
---> statement-breakpoint
-CREATE TABLE "member" (
- "id" text PRIMARY KEY NOT NULL,
- "organizationId" text NOT NULL,
- "userId" text NOT NULL,
- "role" text NOT NULL,
- "createdAt" timestamp NOT NULL
-);
---> statement-breakpoint
-CREATE TABLE "organization" (
- "id" text PRIMARY KEY NOT NULL,
- "name" text NOT NULL,
- "slug" text NOT NULL,
- "logo" text,
- "createdAt" timestamp NOT NULL,
- "metadata" text,
- CONSTRAINT "organization_slug_unique" UNIQUE("slug")
-);
---> statement-breakpoint
-CREATE TABLE "session" (
- "id" text PRIMARY KEY NOT NULL,
- "expiresAt" timestamp NOT NULL,
- "token" text NOT NULL,
- "createdAt" timestamp NOT NULL,
- "updatedAt" timestamp NOT NULL,
- "ipAddress" text,
- "userAgent" text,
- "userId" text NOT NULL,
- "impersonatedBy" text,
- "activeOrganizationId" text,
- CONSTRAINT "session_token_unique" UNIQUE("token")
-);
---> statement-breakpoint
-CREATE TABLE "sites" (
- "site_id" serial PRIMARY KEY NOT NULL,
- "name" text NOT NULL,
- "domain" text NOT NULL,
- "created_at" timestamp DEFAULT now(),
- "updated_at" timestamp DEFAULT now(),
- "created_by" text NOT NULL,
- CONSTRAINT "sites_domain_unique" UNIQUE("domain")
-);
---> statement-breakpoint
-CREATE TABLE "user" (
- "id" text PRIMARY KEY NOT NULL,
- "name" text NOT NULL,
- "username" text NOT NULL,
- "email" text NOT NULL,
- "emailVerified" boolean NOT NULL,
- "image" text,
- "createdAt" timestamp NOT NULL,
- "updatedAt" timestamp NOT NULL,
- "role" text DEFAULT 'user' NOT NULL,
- "displayUsername" text,
- "banned" boolean,
- "banReason" text,
- "banExpires" timestamp,
- CONSTRAINT "user_username_unique" UNIQUE("username"),
- CONSTRAINT "user_email_unique" UNIQUE("email")
-);
---> statement-breakpoint
-CREATE TABLE "verification" (
- "id" text PRIMARY KEY NOT NULL,
- "identifier" text NOT NULL,
- "value" text NOT NULL,
- "expiresAt" timestamp NOT NULL,
- "createdAt" timestamp,
- "updatedAt" timestamp
-);
---> statement-breakpoint
-ALTER TABLE "account" ADD CONSTRAINT "account_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
-ALTER TABLE "member" ADD CONSTRAINT "member_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
-ALTER TABLE "member" ADD CONSTRAINT "member_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
-ALTER TABLE "session" ADD CONSTRAINT "session_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
-ALTER TABLE "sites" ADD CONSTRAINT "sites_created_by_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;
\ No newline at end of file
diff --git a/server/drizzle/0001_sweet_retro_girl.sql b/server/drizzle/0001_sweet_retro_girl.sql
deleted file mode 100644
index 3c9dbcde0..000000000
--- a/server/drizzle/0001_sweet_retro_girl.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-CREATE TABLE "reports" (
- "report_id" serial PRIMARY KEY NOT NULL,
- "site_id" integer,
- "user_id" text,
- "report_type" text,
- "data" jsonb,
- "created_at" timestamp DEFAULT now(),
- "updated_at" timestamp DEFAULT now()
-);
---> statement-breakpoint
-ALTER TABLE "reports" ADD CONSTRAINT "reports_site_id_sites_site_id_fk" FOREIGN KEY ("site_id") REFERENCES "public"."sites"("site_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
-ALTER TABLE "reports" ADD CONSTRAINT "reports_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;
\ No newline at end of file
diff --git a/server/drizzle/meta/0000_snapshot.json b/server/drizzle/meta/0000_snapshot.json
deleted file mode 100644
index 045a6c061..000000000
--- a/server/drizzle/meta/0000_snapshot.json
+++ /dev/null
@@ -1,687 +0,0 @@
-{
- "id": "a1455965-aa57-4090-83fa-c3863fbdca3d",
- "prevId": "00000000-0000-0000-0000-000000000000",
- "version": "7",
- "dialect": "postgresql",
- "tables": {
- "public.account": {
- "name": "account",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "accountId": {
- "name": "accountId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "providerId": {
- "name": "providerId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "accessToken": {
- "name": "accessToken",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "refreshToken": {
- "name": "refreshToken",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "idToken": {
- "name": "idToken",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "accessTokenExpiresAt": {
- "name": "accessTokenExpiresAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- },
- "refreshTokenExpiresAt": {
- "name": "refreshTokenExpiresAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- },
- "scope": {
- "name": "scope",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "password": {
- "name": "password",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "updatedAt": {
- "name": "updatedAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {
- "account_userId_user_id_fk": {
- "name": "account_userId_user_id_fk",
- "tableFrom": "account",
- "tableTo": "user",
- "columnsFrom": [
- "userId"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.active_sessions": {
- "name": "active_sessions",
- "schema": "",
- "columns": {
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "site_id": {
- "name": "site_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "hostname": {
- "name": "hostname",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "start_time": {
- "name": "start_time",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "last_activity": {
- "name": "last_activity",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "pageviews": {
- "name": "pageviews",
- "type": "integer",
- "primaryKey": false,
- "notNull": false,
- "default": 0
- },
- "entry_page": {
- "name": "entry_page",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "exit_page": {
- "name": "exit_page",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "device_type": {
- "name": "device_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "screen_width": {
- "name": "screen_width",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "screen_height": {
- "name": "screen_height",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "browser": {
- "name": "browser",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "operating_system": {
- "name": "operating_system",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "language": {
- "name": "language",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "referrer": {
- "name": "referrer",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.member": {
- "name": "member",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "organizationId": {
- "name": "organizationId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "role": {
- "name": "role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {
- "member_organizationId_organization_id_fk": {
- "name": "member_organizationId_organization_id_fk",
- "tableFrom": "member",
- "tableTo": "organization",
- "columnsFrom": [
- "organizationId"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "member_userId_user_id_fk": {
- "name": "member_userId_user_id_fk",
- "tableFrom": "member",
- "tableTo": "user",
- "columnsFrom": [
- "userId"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization": {
- "name": "organization",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "logo": {
- "name": "logo",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "metadata": {
- "name": "metadata",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "organization_slug_unique": {
- "name": "organization_slug_unique",
- "nullsNotDistinct": false,
- "columns": [
- "slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.session": {
- "name": "session",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "expiresAt": {
- "name": "expiresAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "token": {
- "name": "token",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "updatedAt": {
- "name": "updatedAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "ipAddress": {
- "name": "ipAddress",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "userAgent": {
- "name": "userAgent",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "impersonatedBy": {
- "name": "impersonatedBy",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "activeOrganizationId": {
- "name": "activeOrganizationId",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_userId_user_id_fk": {
- "name": "session_userId_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": [
- "userId"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "session_token_unique": {
- "name": "session_token_unique",
- "nullsNotDistinct": false,
- "columns": [
- "token"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.sites": {
- "name": "sites",
- "schema": "",
- "columns": {
- "site_id": {
- "name": "site_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "domain": {
- "name": "domain",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {
- "sites_created_by_user_id_fk": {
- "name": "sites_created_by_user_id_fk",
- "tableFrom": "sites",
- "tableTo": "user",
- "columnsFrom": [
- "created_by"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "sites_domain_unique": {
- "name": "sites_domain_unique",
- "nullsNotDistinct": false,
- "columns": [
- "domain"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.user": {
- "name": "user",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "username": {
- "name": "username",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "emailVerified": {
- "name": "emailVerified",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true
- },
- "image": {
- "name": "image",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "updatedAt": {
- "name": "updatedAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "role": {
- "name": "role",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'user'"
- },
- "displayUsername": {
- "name": "displayUsername",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "banned": {
- "name": "banned",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "banReason": {
- "name": "banReason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "banExpires": {
- "name": "banExpires",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "user_username_unique": {
- "name": "user_username_unique",
- "nullsNotDistinct": false,
- "columns": [
- "username"
- ]
- },
- "user_email_unique": {
- "name": "user_email_unique",
- "nullsNotDistinct": false,
- "columns": [
- "email"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.verification": {
- "name": "verification",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "identifier": {
- "name": "identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "value": {
- "name": "value",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "expiresAt": {
- "name": "expiresAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- },
- "updatedAt": {
- "name": "updatedAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- }
- },
- "enums": {},
- "schemas": {},
- "sequences": {},
- "roles": {},
- "policies": {},
- "views": {},
- "_meta": {
- "columns": {},
- "schemas": {},
- "tables": {}
- }
-}
\ No newline at end of file
diff --git a/server/drizzle/meta/0001_snapshot.json b/server/drizzle/meta/0001_snapshot.json
deleted file mode 100644
index ce9ed83a7..000000000
--- a/server/drizzle/meta/0001_snapshot.json
+++ /dev/null
@@ -1,771 +0,0 @@
-{
- "id": "b13c246a-71be-4b88-9672-eb0943b3fe19",
- "prevId": "a1455965-aa57-4090-83fa-c3863fbdca3d",
- "version": "7",
- "dialect": "postgresql",
- "tables": {
- "public.account": {
- "name": "account",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "accountId": {
- "name": "accountId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "providerId": {
- "name": "providerId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "accessToken": {
- "name": "accessToken",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "refreshToken": {
- "name": "refreshToken",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "idToken": {
- "name": "idToken",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "accessTokenExpiresAt": {
- "name": "accessTokenExpiresAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- },
- "refreshTokenExpiresAt": {
- "name": "refreshTokenExpiresAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- },
- "scope": {
- "name": "scope",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "password": {
- "name": "password",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "updatedAt": {
- "name": "updatedAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {
- "account_userId_user_id_fk": {
- "name": "account_userId_user_id_fk",
- "tableFrom": "account",
- "tableTo": "user",
- "columnsFrom": [
- "userId"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.active_sessions": {
- "name": "active_sessions",
- "schema": "",
- "columns": {
- "session_id": {
- "name": "session_id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "site_id": {
- "name": "site_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "hostname": {
- "name": "hostname",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "start_time": {
- "name": "start_time",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "last_activity": {
- "name": "last_activity",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "pageviews": {
- "name": "pageviews",
- "type": "integer",
- "primaryKey": false,
- "notNull": false,
- "default": 0
- },
- "entry_page": {
- "name": "entry_page",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "exit_page": {
- "name": "exit_page",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "device_type": {
- "name": "device_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "screen_width": {
- "name": "screen_width",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "screen_height": {
- "name": "screen_height",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "browser": {
- "name": "browser",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "operating_system": {
- "name": "operating_system",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "language": {
- "name": "language",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "referrer": {
- "name": "referrer",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.member": {
- "name": "member",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "organizationId": {
- "name": "organizationId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "role": {
- "name": "role",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {
- "member_organizationId_organization_id_fk": {
- "name": "member_organizationId_organization_id_fk",
- "tableFrom": "member",
- "tableTo": "organization",
- "columnsFrom": [
- "organizationId"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "member_userId_user_id_fk": {
- "name": "member_userId_user_id_fk",
- "tableFrom": "member",
- "tableTo": "user",
- "columnsFrom": [
- "userId"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.organization": {
- "name": "organization",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "slug": {
- "name": "slug",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "logo": {
- "name": "logo",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "metadata": {
- "name": "metadata",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "organization_slug_unique": {
- "name": "organization_slug_unique",
- "nullsNotDistinct": false,
- "columns": [
- "slug"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.reports": {
- "name": "reports",
- "schema": "",
- "columns": {
- "report_id": {
- "name": "report_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "site_id": {
- "name": "site_id",
- "type": "integer",
- "primaryKey": false,
- "notNull": false
- },
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "report_type": {
- "name": "report_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "data": {
- "name": "data",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- }
- },
- "indexes": {},
- "foreignKeys": {
- "reports_site_id_sites_site_id_fk": {
- "name": "reports_site_id_sites_site_id_fk",
- "tableFrom": "reports",
- "tableTo": "sites",
- "columnsFrom": [
- "site_id"
- ],
- "columnsTo": [
- "site_id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "reports_user_id_user_id_fk": {
- "name": "reports_user_id_user_id_fk",
- "tableFrom": "reports",
- "tableTo": "user",
- "columnsFrom": [
- "user_id"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.session": {
- "name": "session",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "expiresAt": {
- "name": "expiresAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "token": {
- "name": "token",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "updatedAt": {
- "name": "updatedAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "ipAddress": {
- "name": "ipAddress",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "userAgent": {
- "name": "userAgent",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "impersonatedBy": {
- "name": "impersonatedBy",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "activeOrganizationId": {
- "name": "activeOrganizationId",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_userId_user_id_fk": {
- "name": "session_userId_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": [
- "userId"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "session_token_unique": {
- "name": "session_token_unique",
- "nullsNotDistinct": false,
- "columns": [
- "token"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.sites": {
- "name": "sites",
- "schema": "",
- "columns": {
- "site_id": {
- "name": "site_id",
- "type": "serial",
- "primaryKey": true,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "domain": {
- "name": "domain",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "created_at": {
- "name": "created_at",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false,
- "default": "now()"
- },
- "created_by": {
- "name": "created_by",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {},
- "foreignKeys": {
- "sites_created_by_user_id_fk": {
- "name": "sites_created_by_user_id_fk",
- "tableFrom": "sites",
- "tableTo": "user",
- "columnsFrom": [
- "created_by"
- ],
- "columnsTo": [
- "id"
- ],
- "onDelete": "no action",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "sites_domain_unique": {
- "name": "sites_domain_unique",
- "nullsNotDistinct": false,
- "columns": [
- "domain"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.user": {
- "name": "user",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "username": {
- "name": "username",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "emailVerified": {
- "name": "emailVerified",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true
- },
- "image": {
- "name": "image",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "updatedAt": {
- "name": "updatedAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "role": {
- "name": "role",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'user'"
- },
- "displayUsername": {
- "name": "displayUsername",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "banned": {
- "name": "banned",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
- "banReason": {
- "name": "banReason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "banExpires": {
- "name": "banExpires",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "user_username_unique": {
- "name": "user_username_unique",
- "nullsNotDistinct": false,
- "columns": [
- "username"
- ]
- },
- "user_email_unique": {
- "name": "user_email_unique",
- "nullsNotDistinct": false,
- "columns": [
- "email"
- ]
- }
- },
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.verification": {
- "name": "verification",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true
- },
- "identifier": {
- "name": "identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "value": {
- "name": "value",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "expiresAt": {
- "name": "expiresAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- },
- "updatedAt": {
- "name": "updatedAt",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- }
- },
- "enums": {},
- "schemas": {},
- "sequences": {},
- "roles": {},
- "policies": {},
- "views": {},
- "_meta": {
- "columns": {},
- "schemas": {},
- "tables": {}
- }
-}
\ No newline at end of file
diff --git a/server/drizzle/meta/_journal.json b/server/drizzle/meta/_journal.json
deleted file mode 100644
index 30131e573..000000000
--- a/server/drizzle/meta/_journal.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "version": "7",
- "dialect": "postgresql",
- "entries": [
- {
- "idx": 0,
- "version": "7",
- "when": 1741156226094,
- "tag": "0000_gorgeous_shriek",
- "breakpoints": true
- },
- {
- "idx": 1,
- "version": "7",
- "when": 1741197517430,
- "tag": "0001_sweet_retro_girl",
- "breakpoints": true
- }
- ]
-}
\ No newline at end of file
diff --git a/server/src/db/postgres/schema.ts b/server/src/db/postgres/schema.ts
index b611da3b5..4952d775b 100644
--- a/server/src/db/postgres/schema.ts
+++ b/server/src/db/postgres/schema.ts
@@ -1,14 +1,11 @@
import {
+ boolean,
+ integer,
+ jsonb,
pgTable,
+ serial,
text,
timestamp,
- integer,
- boolean,
- primaryKey,
- foreignKey,
- serial,
- unique,
- jsonb,
} from "drizzle-orm/pg-core";
// User table
@@ -48,6 +45,7 @@ export const sites = pgTable("sites", {
createdBy: text("created_by")
.notNull()
.references(() => users.id),
+ organizationId: text("organization_id").references(() => organization.id),
});
// Active sessions table