feat: mosaic gateway CLI daemon management + admin token auth (#369)
This commit was merged in pull request #369.
This commit is contained in:
@@ -16,4 +16,5 @@ export {
|
||||
gte,
|
||||
lte,
|
||||
ilike,
|
||||
count,
|
||||
} from 'drizzle-orm';
|
||||
|
||||
@@ -91,6 +91,28 @@ export const verifications = pgTable('verifications', {
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
});
|
||||
|
||||
// ─── Admin API Tokens ───────────────────────────────────────────────────────
|
||||
|
||||
export const adminTokens = pgTable(
|
||||
'admin_tokens',
|
||||
{
|
||||
id: text('id').primaryKey(),
|
||||
userId: text('user_id')
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: 'cascade' }),
|
||||
tokenHash: text('token_hash').notNull(),
|
||||
label: text('label').notNull(),
|
||||
scope: text('scope').notNull().default('admin'),
|
||||
expiresAt: timestamp('expires_at', { withTimezone: true }),
|
||||
lastUsedAt: timestamp('last_used_at', { withTimezone: true }),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(t) => [
|
||||
index('admin_tokens_user_id_idx').on(t.userId),
|
||||
uniqueIndex('admin_tokens_hash_idx').on(t.tokenHash),
|
||||
],
|
||||
);
|
||||
|
||||
// ─── Teams ───────────────────────────────────────────────────────────────────
|
||||
// Declared before projects because projects references teams.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user