Merge branch 'master' into global-bindings
This commit is contained in:
commit
2641224ea0
|
@ -9,8 +9,11 @@ import {
|
||||||
CreateDatasourceResponse,
|
CreateDatasourceResponse,
|
||||||
Datasource,
|
Datasource,
|
||||||
DatasourcePlus,
|
DatasourcePlus,
|
||||||
|
Document,
|
||||||
FetchDatasourceInfoRequest,
|
FetchDatasourceInfoRequest,
|
||||||
FetchDatasourceInfoResponse,
|
FetchDatasourceInfoResponse,
|
||||||
|
FieldType,
|
||||||
|
RelationshipFieldMetadata,
|
||||||
SourceName,
|
SourceName,
|
||||||
UpdateDatasourceResponse,
|
UpdateDatasourceResponse,
|
||||||
UserCtx,
|
UserCtx,
|
||||||
|
@ -218,9 +221,26 @@ async function destroyInternalTablesBySourceId(datasourceId: string) {
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function updateRevisions(deletedLinks: RelationshipFieldMetadata[]) {
|
||||||
|
for (const link of deletedLinks) {
|
||||||
|
datasourceTableDocs.forEach((doc: Document) => {
|
||||||
|
if (doc._id === link.tableId) {
|
||||||
|
doc._rev = link.tableRev
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Destroy the tables.
|
// Destroy the tables.
|
||||||
for (const table of datasourceTableDocs) {
|
for (const table of datasourceTableDocs) {
|
||||||
await sdk.tables.internal.destroy(table)
|
const deleted = await sdk.tables.internal.destroy(table)
|
||||||
|
// Update the revisions of any tables that remain to be deleted
|
||||||
|
const deletedLinks: RelationshipFieldMetadata[] = Object.values(
|
||||||
|
deleted.table.schema
|
||||||
|
)
|
||||||
|
.filter(field => field.type === FieldType.LINK)
|
||||||
|
.map(field => field as RelationshipFieldMetadata)
|
||||||
|
updateRevisions(deletedLinks)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ export const employeeImport = [
|
||||||
type: "row",
|
type: "row",
|
||||||
"Employee Level": ["Senior"],
|
"Employee Level": ["Senior"],
|
||||||
"Start Date": "2015-02-12T12:00:00.000",
|
"Start Date": "2015-02-12T12:00:00.000",
|
||||||
|
"Badge Photo": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"First Name": "Mandy",
|
"First Name": "Mandy",
|
||||||
|
@ -28,6 +29,7 @@ export const employeeImport = [
|
||||||
type: "row",
|
type: "row",
|
||||||
"Employee Level": ["Senior"],
|
"Employee Level": ["Senior"],
|
||||||
"Start Date": "2017-09-10T12:00:00.000",
|
"Start Date": "2017-09-10T12:00:00.000",
|
||||||
|
"Badge Photo": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"First Name": "Holly",
|
"First Name": "Holly",
|
||||||
|
@ -43,6 +45,7 @@ export const employeeImport = [
|
||||||
type: "row",
|
type: "row",
|
||||||
"Employee Level": ["Senior"],
|
"Employee Level": ["Senior"],
|
||||||
"Start Date": "2022-02-12T12:00:00.000",
|
"Start Date": "2022-02-12T12:00:00.000",
|
||||||
|
"Badge Photo": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"First Name": "Francis",
|
"First Name": "Francis",
|
||||||
|
@ -58,6 +61,7 @@ export const employeeImport = [
|
||||||
type: "row",
|
type: "row",
|
||||||
"Employee Level": ["Apprentice"],
|
"Employee Level": ["Apprentice"],
|
||||||
"Start Date": "2021-03-10T12:00:00.000",
|
"Start Date": "2021-03-10T12:00:00.000",
|
||||||
|
"Badge Photo": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"First Name": "Richard",
|
"First Name": "Richard",
|
||||||
|
@ -73,6 +77,7 @@ export const employeeImport = [
|
||||||
type: "row",
|
type: "row",
|
||||||
"Employee Level": ["Apprentice"],
|
"Employee Level": ["Apprentice"],
|
||||||
"Start Date": "2020-07-09T12:00:00.000",
|
"Start Date": "2020-07-09T12:00:00.000",
|
||||||
|
"Badge Photo": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"First Name": "Donald",
|
"First Name": "Donald",
|
||||||
|
@ -88,6 +93,7 @@ export const employeeImport = [
|
||||||
type: "row",
|
type: "row",
|
||||||
"Employee Level": ["Junior"],
|
"Employee Level": ["Junior"],
|
||||||
"Start Date": "2018-04-13T12:00:00.000",
|
"Start Date": "2018-04-13T12:00:00.000",
|
||||||
|
"Badge Photo": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"First Name": "Maria",
|
"First Name": "Maria",
|
||||||
|
@ -103,6 +109,7 @@ export const employeeImport = [
|
||||||
type: "row",
|
type: "row",
|
||||||
"Employee Level": ["Manager"],
|
"Employee Level": ["Manager"],
|
||||||
"Start Date": "2016-05-22T12:00:00.000",
|
"Start Date": "2016-05-22T12:00:00.000",
|
||||||
|
"Badge Photo": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"First Name": "Suzy",
|
"First Name": "Suzy",
|
||||||
|
@ -118,6 +125,7 @@ export const employeeImport = [
|
||||||
type: "row",
|
type: "row",
|
||||||
"Employee Level": ["Senior", "Manager"],
|
"Employee Level": ["Senior", "Manager"],
|
||||||
"Start Date": "2019-05-01T12:00:00.000",
|
"Start Date": "2019-05-01T12:00:00.000",
|
||||||
|
"Badge Photo": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"First Name": "Patrick",
|
"First Name": "Patrick",
|
||||||
|
@ -133,6 +141,7 @@ export const employeeImport = [
|
||||||
type: "row",
|
type: "row",
|
||||||
"Employee Level": ["Apprentice"],
|
"Employee Level": ["Apprentice"],
|
||||||
"Start Date": "2014-08-30T12:00:00.000",
|
"Start Date": "2014-08-30T12:00:00.000",
|
||||||
|
"Badge Photo": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"First Name": "Brayden",
|
"First Name": "Brayden",
|
||||||
|
@ -148,5 +157,6 @@ export const employeeImport = [
|
||||||
type: "row",
|
type: "row",
|
||||||
"Employee Level": ["Contractor"],
|
"Employee Level": ["Contractor"],
|
||||||
"Start Date": "2022-11-09T12:00:00.000",
|
"Start Date": "2022-11-09T12:00:00.000",
|
||||||
|
"Badge Photo": [],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -440,7 +440,7 @@ class LinkController {
|
||||||
if (field.type === FieldTypes.LINK && field.fieldName) {
|
if (field.type === FieldTypes.LINK && field.fieldName) {
|
||||||
const linkedTable = await this._db.get<Table>(field.tableId)
|
const linkedTable = await this._db.get<Table>(field.tableId)
|
||||||
delete linkedTable.schema[field.fieldName]
|
delete linkedTable.schema[field.fieldName]
|
||||||
await this._db.put(linkedTable)
|
field.tableRev = (await this._db.put(linkedTable)).rev
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
logging.logWarn(err?.message, err)
|
logging.logWarn(err?.message, err)
|
||||||
|
|
|
@ -21,6 +21,7 @@ interface BaseRelationshipFieldMetadata
|
||||||
main?: boolean
|
main?: boolean
|
||||||
fieldName: string
|
fieldName: string
|
||||||
tableId: string
|
tableId: string
|
||||||
|
tableRev?: string
|
||||||
subtype?: AutoFieldSubTypes.CREATED_BY | AutoFieldSubTypes.UPDATED_BY
|
subtype?: AutoFieldSubTypes.CREATED_BY | AutoFieldSubTypes.UPDATED_BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue