Add createdBy field on custom object creation (#6529)
In this PR, I'm: - adding createdBy field (type ACTOR) on custom objects when created - moving `name` and `position` default column to the set of columns automatically creation on object creation - fixing a bug on mutations (update / create), if the targetted object has a 'data' custom field, it was conflicting with the payload ==> I feel we need to refactor this part of the code but we can keep this for a bit later as we plan to move out of pg_graphql <img width="1198" alt="image" src="https://github.com/user-attachments/assets/891c4a97-bab1-415c-8551-dabd5996a794">
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
import { TableColumnOptions } from 'typeorm';
|
||||
|
||||
export const customTableDefaultColumns: TableColumnOptions[] = [
|
||||
import { FieldActorSource } from 'src/engine/metadata-modules/field-metadata/composite-types/actor.composite-type';
|
||||
|
||||
export const customTableDefaultColumns = (
|
||||
tableName: string,
|
||||
): TableColumnOptions[] => [
|
||||
{
|
||||
name: 'id',
|
||||
type: 'uuid',
|
||||
@ -22,4 +26,30 @@ export const customTableDefaultColumns: TableColumnOptions[] = [
|
||||
type: 'timestamptz',
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
name: 'position',
|
||||
type: 'float',
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
type: 'text',
|
||||
isNullable: false,
|
||||
default: "'Untitled'",
|
||||
},
|
||||
{
|
||||
name: 'createdBySource',
|
||||
type: 'enum',
|
||||
enumName: `${tableName}_createdBySource_enum`,
|
||||
enum: Object.values(FieldActorSource),
|
||||
isNullable: false,
|
||||
default: `'${FieldActorSource.MANUAL}'`,
|
||||
},
|
||||
{ name: 'createdByWorkspaceMemberId', type: 'uuid', isNullable: true },
|
||||
{
|
||||
name: 'createdByName',
|
||||
type: 'text',
|
||||
isNullable: false,
|
||||
default: "''",
|
||||
},
|
||||
];
|
||||
|
||||
@ -227,7 +227,7 @@ export class WorkspaceMigrationRunnerService {
|
||||
new Table({
|
||||
name: tableName,
|
||||
schema: schemaName,
|
||||
columns: customTableDefaultColumns,
|
||||
columns: customTableDefaultColumns(tableName),
|
||||
}),
|
||||
true,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user