mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(schemas): set scope description to required (#2954)
This commit is contained in:
parent
2676561720
commit
92968c49dd
3 changed files with 21 additions and 2 deletions
|
@ -40,7 +40,7 @@ describe('scopes', () => {
|
|||
expect(scope).toBeTruthy();
|
||||
|
||||
const newScopeName = `new_${scope.name}`;
|
||||
const newScopeDescription = `new_${scope.description ?? ''}`;
|
||||
const newScopeDescription = `new_${scope.description}`;
|
||||
|
||||
const updatesScope = await updateScope(resource.id, scope.id, {
|
||||
name: newScopeName,
|
||||
|
@ -58,6 +58,7 @@ describe('scopes', () => {
|
|||
const createdScope2 = await createScope(resource.id);
|
||||
const response = await updateScope(resource.id, createdScope2.id, {
|
||||
name: createdScope.name,
|
||||
description: '',
|
||||
}).catch((error: unknown) => error);
|
||||
expect(response instanceof HTTPError && response.response.statusCode === 422).toBe(true);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import { sql } from 'slonik';
|
||||
|
||||
import type { AlterationScript } from '../lib/types/alteration.js';
|
||||
|
||||
const alteration: AlterationScript = {
|
||||
up: async (pool) => {
|
||||
await pool.query(sql`
|
||||
ALTER TABLE scopes ALTER COLUMN description SET NOT NULL;
|
||||
`);
|
||||
},
|
||||
down: async (pool) => {
|
||||
await pool.query(sql`
|
||||
ALTER TABLE scopes ALTER COLUMN description DROP NOT NULL;
|
||||
`);
|
||||
},
|
||||
};
|
||||
|
||||
export default alteration;
|
|
@ -2,7 +2,7 @@ create table scopes (
|
|||
id varchar(21) not null,
|
||||
resource_id varchar(21) not null references resources (id) on update cascade on delete cascade,
|
||||
name varchar(256) not null,
|
||||
description text,
|
||||
description text not null,
|
||||
created_at timestamptz not null default(now()),
|
||||
primary key (id)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue