feat: instance invites
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE "invites" (
|
||||
"id" text PRIMARY KEY,
|
||||
"token" text NOT NULL UNIQUE,
|
||||
"created_by" text NOT NULL,
|
||||
"max_uses" integer DEFAULT 1 NOT NULL,
|
||||
"uses" integer DEFAULT 0 NOT NULL,
|
||||
"expires_at" timestamp with time zone NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "invites" ADD CONSTRAINT "invites_created_by_users_id_fkey" FOREIGN KEY ("created_by") REFERENCES "users"("id") ON DELETE CASCADE;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -357,3 +357,20 @@ export const verifications = pgTable(
|
||||
},
|
||||
(table) => [index("verifications_identifier_idx").on(table.identifier)],
|
||||
);
|
||||
|
||||
// Links admins hand out so someone can register while the instance is invite
|
||||
// only. The token is the secret part of the link.
|
||||
export const invites = pgTable(
|
||||
"invites",
|
||||
{
|
||||
id: text("id").primaryKey().$defaultFn(nanoid),
|
||||
token: text("token").notNull().unique(),
|
||||
createdBy: text("created_by")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
maxUses: integer("max_uses").notNull().default(1),
|
||||
uses: integer("uses").notNull().default(0),
|
||||
expiresAt: timestamptz("expires_at").notNull(),
|
||||
createdAt: timestamptz("created_at").defaultNow().notNull(),
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user