feat: add organization settings and invitations

This commit is contained in:
2026-07-02 05:12:35 -07:00
parent a555c9dd23
commit ba8097e583
20 changed files with 2959 additions and 130 deletions

View File

@@ -29,6 +29,14 @@ export const organizations = pgTable("organizations", {
name: text("name").notNull(),
slug: text("slug").notNull(),
status: organizationStatusEnum("status").notNull().default("active"),
registrationEnabled: boolean("registration_enabled").notNull().default(true),
oidcEnabled: boolean("oidc_enabled").notNull().default(false),
oidcIssuerUrl: text("oidc_issuer_url").notNull().default(""),
oidcClientId: text("oidc_client_id").notNull().default(""),
oidcClientSecret: text("oidc_client_secret").notNull().default(""),
oidcScopes: text("oidc_scopes").notNull().default("openid profile email"),
oidcRedirectUri: text("oidc_redirect_uri").notNull().default(""),
oidcAutoProvision: boolean("oidc_auto_provision").notNull().default(false),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
}, (table) => ({
@@ -114,6 +122,23 @@ export const joinRequests = pgTable("join_requests", {
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
});
export const organizationInvitations = pgTable("organization_invitations", {
id: uuid("id").primaryKey().defaultRandom(),
organizationId: uuid("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
roleId: uuid("role_id").notNull().references(() => roles.id),
email: text("email").notNull().default(""),
token: text("token").notNull(),
status: text("status").notNull().default("active"),
createdByAccountId: uuid("created_by_account_id").references(() => accounts.id),
acceptedByAccountId: uuid("accepted_by_account_id").references(() => accounts.id),
acceptedAt: timestamp("accepted_at", { withTimezone: true }),
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
}, (table) => ({
tokenUnique: uniqueIndex("organization_invitations_token_unique").on(table.token),
}));
export const campuses = pgTable("campuses", {
id: uuid("id").primaryKey().defaultRandom(),
organizationId: uuid("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),