-
Notifications
You must be signed in to change notification settings - Fork 41.7k
feat(core): Add Data Store Backend API (no-changelog) #17824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 98 commits
Commits
Show all changes
119 commits
Select commit
Hold shift + click to select a range
046b88e
initial module commit
CharlieKolb 454db2f
Add functional backend skeleton
CharlieKolb ada6537
untested wip code
CharlieKolb cc24e98
add working tests
CharlieKolb 973c1c9
Working list API
CharlieKolb cf6df74
expose endpoints
CharlieKolb 507bcd0
add test for joining columns
CharlieKolb 309e5d8
test pagination
CharlieKolb 3e11e93
add sort by tests
CharlieKolb 9318e6e
Add row-based operations
CharlieKolb 8b469ff
expose apis
CharlieKolb 0e7d5ac
also expose getColumns
CharlieKolb 9fcbb9f
fix file casing
CharlieKolb 0695ed0
Rename API, adjust dtos and include project scopes
CharlieKolb 01900d5
self review
CharlieKolb 331fc9b
wip commit
CharlieKolb 85a6230
fix build and add tests for shiftColumns
CharlieKolb 0f8e2b1
implement column moving
CharlieKolb cb0455a
throw errors instead of returning strings
CharlieKolb b4a10a3
rename endpoints, modify update dto, fix flaky test
dariacodes 0ff50cf
fix sql utils test
dariacodes 33f7afe
apply interface and more types
CharlieKolb 1e8a78f
fix tests
CharlieKolb 461d23c
fix import for sql utils test
dariacodes 2b26741
improve insert rows endpoint and tests
dariacodes 70cb3b6
prevent SQL injection by quoting column names and using parameter bin…
dariacodes b1a2b05
Add upsert endpoint
dariacodes fa33743
Merge remote-tracking branch 'origin/master' into ADO-3851
CharlieKolb ade6eba
clean up Do The Thing button and adjust api
CharlieKolb 8434c5a
fix build
CharlieKolb e8146a6
captalize file name correctly
CharlieKolb 7967864
Fix permissions type errors
dariacodes 8e6811d
self review
CharlieKolb e13746d
attempt to fix db issues
CharlieKolb eb5b4b8
lint
CharlieKolb a0a4ac0
fix tests
CharlieKolb 8ba6878
try catch instead
CharlieKolb 1453658
remove experiments
CharlieKolb 96e7f6e
Merge remote-tracking branch 'origin/master' into ADO-3851
CharlieKolb 9d37427
Merge remote-tracking branch 'origin/master' into ADO-3851
CharlieKolb 419f517
fix query and type
CharlieKolb 23d6a84
Merge remote-tracking branch 'origin/master' into ADO-3851
CharlieKolb c0c8eac
fix(core): Fix some DataStore backend API issues (#17978)
ivov 5124f2b
fix import on frontend
dariacodes 3201399
fix permissions test
dariacodes 305e321
add transactions for column operations
CharlieKolb 0079c9c
add transactions to data store operations
CharlieKolb 0ad74e4
refactor existing table check
CharlieKolb 815688b
remove unused code
CharlieKolb 205078f
remove IDataStoreService interface and use RegExp
CharlieKolb 7f0655e
Add dataStoreShared endpoint and readd start/shutdown
CharlieKolb 43c00c7
fix lint and unit tests
CharlieKolb 1663e6f
avoid nested transaction
CharlieKolb 21b12eb
use entityManager in transaction
CharlieKolb 9490926
ai feedback
CharlieKolb b4c4be8
fix local build
CharlieKolb 70e0485
use DSL for table creation
dariacodes f05e13f
use rows instead of using api directly
CharlieKolb c96dcca
remove data-store from defaultModules
CharlieKolb fe24022
fix module test
dariacodes 946aa47
improve create table tests
dariacodes b756b04
use DSL for table deletion
dariacodes aa3fb84
Merge branch 'master' into ADO-3851
dariacodes 82fe47b
fix import on frontend
dariacodes c41af20
use DSL for deleteDataStoreAll
dariacodes 543ff08
Merge branch 'master' into ADO-3851
dariacodes 0aa67ca
put data-stores back to registry for tests to pass
dariacodes 7796b75
use the right quoting identifier
dariacodes f31d530
switch back to raw create table
dariacodes 5acd853
switch to timestamp for postgres, update test with hasTable
dariacodes 20c75e0
improve tests
dariacodes 7c8a9ed
Merge branch 'master' into ADO-3851
dariacodes fe7a8f7
hide module from the registry
dariacodes 14def7a
add columns on create, user table on add column, quote table names, i…
dariacodes 954a174
fix orderBy statement for postgres, fix sorting tests for sqlite, ski…
dariacodes 3dbf414
update sql utils test
dariacodes 3194867
fix type errors
dariacodes 1841914
return loadModules back
dariacodes 3da0eda
another attempt to fix types
dariacodes 4c8b074
wait 1 sec for date ops for all the dbs
dariacodes 98598b9
order columns by columnIndex for getColumns to ensure the same result…
dariacodes f0d5ac1
fix orderBy query
dariacodes 4821a7f
add order by columnIndex to join query
dariacodes 5e8f65d
sort columns manually
dariacodes 59fee3a
fix insert functionality, normalize rows
dariacodes ac57b61
fix build update query, unify style
dariacodes 045b0e1
transform dates for sqlite and mariadb
dariacodes 26a036a
update sql-utils test
dariacodes 61e72e3
fix value normalization
dariacodes edcf020
use quoted fields and table name for upsert
dariacodes b580cba
stop checking order for test failing for mariadb
dariacodes 9bbcfd9
rename shared data store service, add a test
dariacodes 3ed0dc4
remove unused repositories from test
dariacodes 9adb2f5
return only data stores user has access to, add more tests
dariacodes 515fee9
remove type warnings
dariacodes 2d0d9b8
remove unused dtos
dariacodes 8527674
use explicit project scopes
dariacodes 91069c1
refactor(core): Avoid type casts
Cadiac 4551e64
add a project scope to data store aggregate
dariacodes 205a612
remove migration
dariacodes bc9ff11
Merge branch 'master' into ADO-3851
dariacodes 8afdfce
rename columnIndex to index
dariacodes 44a8c93
remove entity from data store table names
dariacodes 933a47d
rename entities
dariacodes 62a5f37
include data-store as module
dariacodes 7270296
discard migration changes
dariacodes e0cae29
add createdAt and updatedAt to column entity
dariacodes a05ecf7
test(core): Expect data-store to be missing from eligibleModules by d…
Cadiac e9e51b4
move create user table logic to rows repository
dariacodes c647a90
Merge branch 'master' into ADO-3851
dariacodes 3c5e814
rename data store entity for new files
dariacodes 2ef3816
move drop column from table to rows repository
dariacodes 526a676
clean up
dariacodes fe8935d
remove getPrimaryKeyAutoIncrement
dariacodes f4ee35b
fix(core): Fix data store read rows endpoint
Cadiac 81004be
populate data store create with project
dariacodes a43e4d2
fix(core): Parse row read filters from query params correctly
Cadiac 69842f5
fix ts errors in test
dariacodes 79af2d2
fix(editor): change the delete column endpoint to not take request body
Cadiac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/@n8n/api-types/src/dto/data-store/add-data-store-column.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Z } from 'zod-class'; | ||
|
||
import { dataStoreCreateColumnSchema } from '../../schemas/data-store.schema'; | ||
|
||
export class AddDataStoreColumnDto extends Z.class(dataStoreCreateColumnSchema.shape) {} |
8 changes: 8 additions & 0 deletions
8
packages/@n8n/api-types/src/dto/data-store/add-data-store-rows.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
import { dataStoreColumnNameSchema } from '../../schemas/data-store.schema'; | ||
|
||
export class AddDataStoreRowsDto extends Z.class({ | ||
data: z.array(z.record(dataStoreColumnNameSchema, z.any())), | ||
}) {} |
11 changes: 11 additions & 0 deletions
11
packages/@n8n/api-types/src/dto/data-store/create-data-store-column.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Z } from 'zod-class'; | ||
|
||
import { | ||
dataStoreColumnNameSchema, | ||
dataStoreColumnTypeSchema, | ||
} from '../../schemas/data-store.schema'; | ||
|
||
export class CreateDataStoreColumnDto extends Z.class({ | ||
name: dataStoreColumnNameSchema, | ||
type: dataStoreColumnTypeSchema, | ||
}) {} |
10 changes: 10 additions & 0 deletions
10
packages/@n8n/api-types/src/dto/data-store/create-data-store.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
import { CreateDataStoreColumnDto } from './create-data-store-column.dto'; | ||
import { dataStoreNameSchema } from '../../schemas/data-store.schema'; | ||
|
||
export class CreateDataStoreDto extends Z.class({ | ||
name: dataStoreNameSchema, | ||
columns: z.array(CreateDataStoreColumnDto), | ||
}) {} |
6 changes: 6 additions & 0 deletions
6
packages/@n8n/api-types/src/dto/data-store/delete-data-store-column.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
export class DeleteDataStoreColumnDto extends Z.class({ | ||
columnId: z.string(), | ||
}) {} |
76 changes: 76 additions & 0 deletions
76
packages/@n8n/api-types/src/dto/data-store/list-data-store-content-query.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
import { dataStoreColumnNameSchema } from '../../schemas/data-store.schema'; | ||
import { paginationSchema } from '../pagination/pagination.dto'; | ||
|
||
const FilterConditionSchema = z.union([z.literal('eq'), z.literal('neq')]); | ||
export type ListDataStoreContentFilterConditionType = z.infer<typeof FilterConditionSchema>; | ||
|
||
const filterRecord = z.object({ | ||
columnName: dataStoreColumnNameSchema, | ||
condition: FilterConditionSchema.default('eq'), | ||
value: z.union([z.string(), z.number(), z.boolean(), z.date()]), | ||
}); | ||
|
||
const chainedFilterSchema = z.union([z.literal('and'), z.literal('or')]); | ||
|
||
export type ListDataStoreContentFilter = z.infer<typeof filterValidator>; | ||
|
||
// --------------------- | ||
// Parameter Validators | ||
// --------------------- | ||
|
||
// Filter parameter validation | ||
const filterValidator = z.object({ | ||
type: chainedFilterSchema.default('and'), | ||
filters: z.array(filterRecord).default([]), | ||
}); | ||
|
||
// SortBy parameter validation | ||
const sortByValidator = z | ||
.string() | ||
.optional() | ||
.transform((val, ctx) => { | ||
if (val === undefined) return val; | ||
|
||
if (!val.includes(':')) { | ||
ctx.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: 'Invalid sort format, expected <columnName>:<asc/desc>', | ||
path: ['sort'], | ||
}); | ||
return z.NEVER; | ||
} | ||
|
||
let [column, direction] = val.split(':'); | ||
|
||
try { | ||
column = dataStoreColumnNameSchema.parse(column); | ||
} catch { | ||
ctx.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: 'Invalid sort columnName', | ||
path: ['sort'], | ||
}); | ||
return z.NEVER; | ||
} | ||
|
||
direction = direction?.toUpperCase(); | ||
if (direction !== 'ASC' && direction !== 'DESC') { | ||
ctx.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: 'Invalid sort direction', | ||
path: ['sort'], | ||
}); | ||
|
||
return z.NEVER; | ||
} | ||
return [column, direction] as const; | ||
}); | ||
|
||
export class ListDataStoreContentQueryDto extends Z.class({ | ||
...paginationSchema, | ||
filter: filterValidator, | ||
sortBy: sortByValidator, | ||
}) {} |
70 changes: 70 additions & 0 deletions
70
packages/@n8n/api-types/src/dto/data-store/list-data-store-query.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { jsonParse } from 'n8n-workflow'; | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
import { paginationSchema } from '../pagination/pagination.dto'; | ||
|
||
const VALID_SORT_OPTIONS = [ | ||
'name:asc', | ||
'name:desc', | ||
'createdAt:asc', | ||
'createdAt:desc', | ||
'updatedAt:asc', | ||
'updatedAt:desc', | ||
'sizeBytes:asc', | ||
'sizeBytes:desc', | ||
] as const; | ||
|
||
export type ListDataStoreQuerySortOptions = (typeof VALID_SORT_OPTIONS)[number]; | ||
|
||
const FILTER_OPTIONS = { | ||
id: z.union([z.string(), z.array(z.string())]).optional(), | ||
name: z.union([z.string(), z.array(z.string())]).optional(), | ||
projectId: z.union([z.string(), z.array(z.string())]).optional(), | ||
// todo: can probably include others here as well? | ||
}; | ||
|
||
// Filter schema - only allow specific properties | ||
const filterSchema = z.object(FILTER_OPTIONS).strict(); | ||
// --------------------- | ||
// Parameter Validators | ||
// --------------------- | ||
|
||
// Filter parameter validation | ||
const filterValidator = z | ||
.string() | ||
.optional() | ||
.transform((val, ctx) => { | ||
if (!val) return undefined; | ||
try { | ||
const parsed: unknown = jsonParse(val); | ||
try { | ||
return filterSchema.parse(parsed); | ||
} catch (e) { | ||
ctx.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: 'Invalid filter fields', | ||
path: ['filter'], | ||
}); | ||
return z.NEVER; | ||
} | ||
} catch (e) { | ||
ctx.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: 'Invalid filter format', | ||
path: ['filter'], | ||
}); | ||
return z.NEVER; | ||
} | ||
}); | ||
|
||
// SortBy parameter validation | ||
const sortByValidator = z | ||
.enum(VALID_SORT_OPTIONS, { message: `sortBy must be one of: ${VALID_SORT_OPTIONS.join(', ')}` }) | ||
.optional(); | ||
|
||
export class ListDataStoreQueryDto extends Z.class({ | ||
...paginationSchema, | ||
filter: filterValidator, | ||
sortBy: sortByValidator, | ||
}) {} |
6 changes: 6 additions & 0 deletions
6
packages/@n8n/api-types/src/dto/data-store/move-data-store-column.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
export class MoveDataStoreColumnDto extends Z.class({ | ||
targetIndex: z.number(), | ||
}) {} |
7 changes: 7 additions & 0 deletions
7
packages/@n8n/api-types/src/dto/data-store/update-data-store.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Z } from 'zod-class'; | ||
|
||
import { dataStoreNameSchema } from '../../schemas/data-store.schema'; | ||
|
||
export class UpdateDataStoreDto extends Z.class({ | ||
name: dataStoreNameSchema, | ||
}) {} |
13 changes: 13 additions & 0 deletions
13
packages/@n8n/api-types/src/dto/data-store/upsert-data-store-rows.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
import { dataStoreColumnNameSchema } from '../../schemas/data-store.schema'; | ||
|
||
const dataStoreValueSchema = z.union([z.string(), z.number(), z.boolean(), z.date(), z.null()]); | ||
|
||
const upsertDataStoreRowsShape = { | ||
rows: z.array(z.record(dataStoreValueSchema)), | ||
CharlieKolb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
matchFields: z.array(dataStoreColumnNameSchema).min(1), | ||
}; | ||
|
||
export class UpsertDataStoreRowsDto extends Z.class(upsertDataStoreRowsShape) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { z } from 'zod'; | ||
|
||
import type { ListDataStoreQueryDto } from '../dto'; | ||
|
||
export const dataStoreNameSchema = z.string().trim().min(1).max(128); | ||
export const dataStoreIdSchema = z.string().max(36); | ||
|
||
export const DATA_STORE_COLUMN_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9-]*$/; | ||
|
||
export const dataStoreColumnNameSchema = z | ||
.string() | ||
.trim() | ||
.min(1) | ||
.max(128) | ||
.regex( | ||
DATA_STORE_COLUMN_REGEX, | ||
'Only alphanumeric characters and non-leading dashes are allowed for column names', | ||
); | ||
export const dataStoreColumnTypeSchema = z.enum(['string', 'number', 'boolean', 'date']); | ||
|
||
export const dataStoreCreateColumnSchema = z.object({ | ||
name: dataStoreColumnNameSchema, | ||
type: dataStoreColumnTypeSchema, | ||
columnIndex: z.number().optional(), | ||
}); | ||
export type DataStoreCreateColumnSchema = z.infer<typeof dataStoreCreateColumnSchema>; | ||
|
||
export const dataStoreColumnSchema = dataStoreCreateColumnSchema.extend({ | ||
dataStoreId: dataStoreIdSchema, | ||
}); | ||
|
||
export const dataStoreSchema = z.object({ | ||
id: dataStoreIdSchema, | ||
name: dataStoreNameSchema, | ||
columns: z.array(dataStoreColumnSchema), | ||
createdAt: z.string().datetime(), | ||
updatedAt: z.string().datetime(), | ||
}); | ||
export type DataStore = z.infer<typeof dataStoreSchema>; | ||
export type DataStoreColumn = z.infer<typeof dataStoreColumnSchema>; | ||
|
||
export type DataStoreUserTableName = `data_store_user_${string}`; | ||
|
||
export type DataStoreListFilter = { | ||
id?: string | string[]; | ||
projectId?: string | string[]; | ||
name?: string; | ||
}; | ||
|
||
export type DataStoreListOptions = Partial<ListDataStoreQueryDto> & { | ||
filter: { projectId: string }; | ||
}; | ||
|
||
export type DataStoreColumnJsType = string | number | boolean | Date; | ||
|
||
export type DataStoreRows = Array<Record<string, DataStoreColumnJsType | null>>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/@n8n/db/src/migrations/common/1747814180618-CreateDataStoreTables.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { MigrationContext, ReversibleMigration } from '../migration-types'; | ||
|
||
const dataStoreTableName = 'data_store_entity'; | ||
const dataStoreColumnTableName = 'data_store_column_entity'; | ||
|
||
export class CreateDataStoreTables1747814180618 implements ReversibleMigration { | ||
async up({ schemaBuilder: { createTable, column } }: MigrationContext) { | ||
await createTable(dataStoreTableName) | ||
.withColumns( | ||
column('id').varchar(36).primary.notNull, | ||
column('name').varchar(128).notNull, | ||
column('projectId').varchar(36).notNull, | ||
column('sizeBytes').int.default(0).notNull, | ||
) | ||
.withForeignKey('projectId', { | ||
tableName: 'project', | ||
columnName: 'id', | ||
onDelete: 'CASCADE', | ||
}) | ||
.withIndexOn(['projectId', 'name'], true).withTimestamps; | ||
|
||
await createTable(dataStoreColumnTableName) | ||
.withColumns( | ||
column('id').varchar(36).primary.notNull, | ||
column('name').varchar(128).notNull, | ||
column('type').varchar(32).notNull, | ||
column('columnIndex').int.notNull, | ||
column('dataStoreId').varchar(36).notNull, | ||
) | ||
.withForeignKey('dataStoreId', { | ||
tableName: dataStoreTableName, | ||
columnName: 'id', | ||
onDelete: 'CASCADE', | ||
}) | ||
.withIndexOn(['dataStoreId', 'name'], true).withTimestamps; | ||
} | ||
|
||
async down({ schemaBuilder: { dropTable } }: MigrationContext) { | ||
await dropTable(dataStoreTableName); | ||
await dropTable(dataStoreColumnTableName); | ||
|
||
// @Review: Should we also drop all created user tables here? | ||
dariacodes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for later: we really need to find a way to factorize all those filter validator (same in list-folder-query.dto and users-list-filter.dto)