mirror of
https://github.com/logto-io/logto.git
synced 2025-01-27 21:39:16 -05:00
feat(core): add role table seed (#1145)
* fix(core): add default role db seed add defaylt role db seed * fix(table): add role table default seed add role table default seed * fix(db): cr fix cr fix
This commit is contained in:
parent
bd724a5c4f
commit
837ad523ce
3 changed files with 19 additions and 2 deletions
|
@ -2,7 +2,6 @@ import { readdir, readFile } from 'fs/promises';
|
|||
import path from 'path';
|
||||
|
||||
import { SchemaLike, seeds } from '@logto/schemas';
|
||||
import { createDemoAppApplication } from '@logto/schemas/lib/seeds';
|
||||
import { conditionalString } from '@silverhand/essentials';
|
||||
import chalk from 'chalk';
|
||||
import decamelize from 'decamelize';
|
||||
|
@ -14,7 +13,13 @@ import { fromRoot } from '@/env-set/parameters';
|
|||
|
||||
import { convertToPrimitiveOrSql } from './utils';
|
||||
|
||||
const { managementResource, defaultSignInExperience, createDefaultSetting } = seeds;
|
||||
const {
|
||||
managementResource,
|
||||
defaultSignInExperience,
|
||||
createDefaultSetting,
|
||||
createDemoAppApplication,
|
||||
defaultRole,
|
||||
} = seeds;
|
||||
const tableDirectory =
|
||||
conditionalString(fromRoot && 'packages/core/') + 'node_modules/@logto/schemas/tables';
|
||||
|
||||
|
@ -84,6 +89,7 @@ export const createDatabaseCli = (dsn: string, demoAppUrl: string) => {
|
|||
pool.query(insertInto(createDefaultSetting(), 'settings')),
|
||||
pool.query(insertInto(defaultSignInExperience, 'sign_in_experiences')),
|
||||
pool.query(insertInto(createDemoAppApplication([demoAppUrl]), 'applications')),
|
||||
pool.query(insertInto(defaultRole, 'roles')),
|
||||
]);
|
||||
console.log(`${chalk.blue('[seed-tables]')} Seed tables succeeded.`);
|
||||
};
|
||||
|
|
|
@ -2,3 +2,4 @@ export * from './application';
|
|||
export * from './resource';
|
||||
export * from './setting';
|
||||
export * from './sign-in-experience';
|
||||
export * from './roles';
|
||||
|
|
10
packages/schemas/src/seeds/roles.ts
Normal file
10
packages/schemas/src/seeds/roles.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { CreateRole } from '../db-entries';
|
||||
import { UserRole } from '../types';
|
||||
|
||||
/**
|
||||
* Default Admin Role for Admin Console.
|
||||
*/
|
||||
export const defaultRole: Readonly<CreateRole> = {
|
||||
name: UserRole.Admin,
|
||||
description: 'Admin role for Logto.',
|
||||
};
|
Loading…
Add table
Reference in a new issue