mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
missing files
This commit is contained in:
parent
3f8408f855
commit
e1453b905b
|
@ -0,0 +1,20 @@
|
|||
import { z } from 'zod';
|
||||
import { Z } from 'zod-class';
|
||||
|
||||
export const KEY_NAME_REGEX = /^[A-Za-z0-9_]+$/;
|
||||
export const VALUE_MAX_LENGTH = 255;
|
||||
export const TYPE_ENUM = ['string'] as const;
|
||||
export const TYPE_DEFAULT: (typeof TYPE_ENUM)[number] = 'string';
|
||||
|
||||
export class CreateVariableRequestDto extends Z.class({
|
||||
key: z
|
||||
.string()
|
||||
.min(1, 'key must be at least 1 character long')
|
||||
.max(50, 'key cannot be longer than 50 characters')
|
||||
.regex(KEY_NAME_REGEX, 'key can only contain characters A-Za-z0-9_'),
|
||||
type: z.enum(TYPE_ENUM).default(TYPE_DEFAULT),
|
||||
value: z
|
||||
.string()
|
||||
.max(VALUE_MAX_LENGTH, `value cannot be longer than ${VALUE_MAX_LENGTH} characters`),
|
||||
projectId: z.string().length(36).optional().nullable().default(null),
|
||||
}) {}
|
|
@ -0,0 +1,12 @@
|
|||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
|
||||
export class AddProjectToVariables1729695079000 implements ReversibleMigration {
|
||||
async up({ schemaBuilder: { addColumns, column, addForeignKey } }: MigrationContext) {
|
||||
await addColumns('variables', [column('projectId').varchar(36)]);
|
||||
await addForeignKey('variables', 'projectId', ['project', 'id']);
|
||||
}
|
||||
|
||||
async down({ schemaBuilder: { dropColumns } }: MigrationContext) {
|
||||
await dropColumns('variables', ['projectId']);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue