mirror of
https://github.com/nestriness/nestri.git
synced 2026-08-01 17:34:15 +03:00
feat: Add member table
This commit is contained in:
@@ -49,4 +49,11 @@ export namespace Examples {
|
|||||||
name: "Example App",
|
name: "Example App",
|
||||||
redirectURI: "https://web.example.com/v1/callback",
|
redirectURI: "https://web.example.com/v1/callback",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const Member = {
|
||||||
|
id: Id("member"),
|
||||||
|
ownerID: User.id,
|
||||||
|
orgID: Organisation.id,
|
||||||
|
role: "admin" as const,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
22
packages/core/src/member/member.sql.ts
Normal file
22
packages/core/src/member/member.sql.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { userTable } from "../user/user.sql.js";
|
||||||
|
import { orgTable } from "../organisation/org.sql.js";
|
||||||
|
import { pgEnum, pgTable } from "drizzle-orm/pg-core";
|
||||||
|
import { id, ulid, timestamps } from "../drizzle/types.js";
|
||||||
|
|
||||||
|
export const MemberRole = pgEnum("role", ["admin", "member", "admin"]);
|
||||||
|
|
||||||
|
export const memberTable = pgTable("members", {
|
||||||
|
...id,
|
||||||
|
...timestamps,
|
||||||
|
orgID: ulid("organisation_id")
|
||||||
|
.references(() => orgTable.id, {
|
||||||
|
onDelete: "cascade",
|
||||||
|
})
|
||||||
|
.notNull(),
|
||||||
|
ownerID: ulid("owner_id")
|
||||||
|
.references(() => userTable.id, {
|
||||||
|
onDelete: "cascade",
|
||||||
|
})
|
||||||
|
.notNull(),
|
||||||
|
role: MemberRole("role").notNull(),
|
||||||
|
});
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
import { id, timestamps, ulid } from "../drizzle/types.js";
|
|
||||||
import { pgTable, varchar } from "drizzle-orm/pg-core";
|
|
||||||
import { userTable } from "../user/user.sql.js";
|
import { userTable } from "../user/user.sql.js";
|
||||||
|
import { pgTable, varchar } from "drizzle-orm/pg-core";
|
||||||
|
import { id, timestamps, ulid } from "../drizzle/types.js";
|
||||||
|
|
||||||
export const orgTable = pgTable("organisations", {
|
export const orgTable = pgTable("organisations", {
|
||||||
...id,
|
...id,
|
||||||
...timestamps,
|
...timestamps,
|
||||||
ownerID: ulid("owner_id").references(() => userTable.id, {
|
ownerID: ulid("owner_id")
|
||||||
|
.references(() => userTable.id, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
}),
|
})
|
||||||
|
.notNull(),
|
||||||
name: varchar("name", { length: 255 }).unique().notNull(),
|
name: varchar("name", { length: 255 }).unique().notNull(),
|
||||||
slug: varchar("slug", { length: 255 }).unique().notNull(),
|
slug: varchar("slug", { length: 255 }).unique().notNull(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,9 +32,11 @@ export type Limitations = z.infer<typeof Limitations>;
|
|||||||
export const steamTable = pgTable("steam_accounts", {
|
export const steamTable = pgTable("steam_accounts", {
|
||||||
...timestamps,
|
...timestamps,
|
||||||
id: varchar("id", { length: 255 }).primaryKey().notNull(),
|
id: varchar("id", { length: 255 }).primaryKey().notNull(),
|
||||||
ownerID: ulid("owner_id").references(() => userTable.id, {
|
ownerID: ulid("owner_id")
|
||||||
|
.references(() => userTable.id, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
}),
|
})
|
||||||
|
.notNull(),
|
||||||
memberSince: utc("member_since").notNull(),
|
memberSince: utc("member_since").notNull(),
|
||||||
name: varchar("name", { length: 255 }).notNull(),
|
name: varchar("name", { length: 255 }).notNull(),
|
||||||
lastSyncedAt: utc("last_synced_at").notNull(),
|
lastSyncedAt: utc("last_synced_at").notNull(),
|
||||||
|
|||||||
Reference in New Issue
Block a user