@tanglemedia/directus-core-settings 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const FLEX_CONTENT_COLLECTION = "tngl_flex_content";
|
|
2
|
+
const FLEX_CONTENT_FIELD = "tngl_flx_cntnt";
|
|
3
|
+
|
|
4
|
+
// Adds the tngl_flx_cntnt foreign key column and registers it in Directus for a given collection.
|
|
5
|
+
// Safe to call if tngl_flex_content isn't installed yet or the field already exists.
|
|
6
|
+
export async function addFlexContentField(knex, collectionName) {
|
|
7
|
+
const flexContentExists = await knex.schema.hasTable(FLEX_CONTENT_COLLECTION);
|
|
8
|
+
if (!flexContentExists) return;
|
|
9
|
+
|
|
10
|
+
const fieldExists = await knex.schema.hasColumn(collectionName, FLEX_CONTENT_FIELD);
|
|
11
|
+
if (fieldExists) return;
|
|
12
|
+
|
|
13
|
+
await knex.schema.alterTable(collectionName, (table) => {
|
|
14
|
+
table.uuid(FLEX_CONTENT_FIELD).nullable();
|
|
15
|
+
table
|
|
16
|
+
.foreign(FLEX_CONTENT_FIELD)
|
|
17
|
+
.references("id")
|
|
18
|
+
.inTable(FLEX_CONTENT_COLLECTION)
|
|
19
|
+
.onDelete("SET NULL");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
await knex("directus_fields").insert({
|
|
23
|
+
collection: collectionName,
|
|
24
|
+
field: FLEX_CONTENT_FIELD,
|
|
25
|
+
special: "m2o",
|
|
26
|
+
interface: "inline-form-m2o",
|
|
27
|
+
options: null,
|
|
28
|
+
display: null,
|
|
29
|
+
display_options: null,
|
|
30
|
+
readonly: false,
|
|
31
|
+
hidden: false,
|
|
32
|
+
sort: 29,
|
|
33
|
+
width: "full",
|
|
34
|
+
translations: JSON.stringify([
|
|
35
|
+
{ language: "en-US", translation: " " },
|
|
36
|
+
{ language: "en-CA", translation: " " },
|
|
37
|
+
]),
|
|
38
|
+
note: null,
|
|
39
|
+
conditions: null,
|
|
40
|
+
required: false,
|
|
41
|
+
group: null,
|
|
42
|
+
validation: null,
|
|
43
|
+
validation_message: null,
|
|
44
|
+
});
|
|
45
|
+
}
|