mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Add migrations
This commit is contained in:
109
api/src/database/migrations/20201029A-remove-system-relations.ts
Normal file
109
api/src/database/migrations/20201029A-remove-system-relations.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import Knex from 'knex';
|
||||
|
||||
export async function up(knex: Knex) {
|
||||
await knex('directus_relations')
|
||||
.delete()
|
||||
.where('many_collection', 'like', 'directus_%')
|
||||
.andWhere('one_collection', 'like', 'directus_%');
|
||||
}
|
||||
|
||||
export async function down(knex: Knex) {
|
||||
const systemRelations = [
|
||||
{
|
||||
many_collection: 'directus_users',
|
||||
many_field: 'role',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_roles',
|
||||
one_field: 'users',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_users',
|
||||
many_field: 'avatar',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_files',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_revisions',
|
||||
many_field: 'activity',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_activity',
|
||||
one_field: 'revisions',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_presets',
|
||||
many_field: 'user',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_users',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_presets',
|
||||
many_field: 'role',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_roles',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_folders',
|
||||
many_field: 'parent',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_folders',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_files',
|
||||
many_field: 'folder',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_folders',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_files',
|
||||
many_field: 'uploaded_by',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_users',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_fields',
|
||||
many_field: 'collection',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_collections',
|
||||
one_field: 'fields',
|
||||
one_primary: 'collection',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_activity',
|
||||
many_field: 'user',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_users',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_settings',
|
||||
many_field: 'project_logo',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_files',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_settings',
|
||||
many_field: 'public_foreground',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_files',
|
||||
one_primary: 'id',
|
||||
},
|
||||
{
|
||||
many_collection: 'directus_settings',
|
||||
many_field: 'public_background',
|
||||
many_primary: 'id',
|
||||
one_collection: 'directus_files',
|
||||
one_primary: 'id',
|
||||
},
|
||||
];
|
||||
|
||||
await knex.insert(systemRelations).into('directus_relations');
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import Knex from 'knex';
|
||||
|
||||
export async function up(knex: Knex) {
|
||||
await knex('directus_collections').delete().where('collection', 'like', 'directus_%');
|
||||
}
|
||||
|
||||
export async function down(knex: Knex) {
|
||||
const systemCollections = [
|
||||
{
|
||||
collection: 'directus_activity',
|
||||
note: 'Accountability logs for all events',
|
||||
},
|
||||
{
|
||||
collection: 'directus_collections',
|
||||
icon: 'list_alt',
|
||||
note: 'Additional collection configuration and metadata',
|
||||
},
|
||||
{
|
||||
collection: 'directus_fields',
|
||||
icon: 'input',
|
||||
note: 'Additional field configuration and metadata',
|
||||
},
|
||||
{
|
||||
collection: 'directus_files',
|
||||
icon: 'folder',
|
||||
note: 'Metadata for all managed file assets',
|
||||
},
|
||||
{
|
||||
collection: 'directus_folders',
|
||||
note: 'Provides virtual directories for files',
|
||||
},
|
||||
{
|
||||
collection: 'directus_permissions',
|
||||
icon: 'admin_panel_settings',
|
||||
note: 'Access permissions for each role',
|
||||
},
|
||||
{
|
||||
collection: 'directus_presets',
|
||||
icon: 'bookmark_border',
|
||||
note: 'Presets for collection defaults and bookmarks',
|
||||
},
|
||||
{
|
||||
collection: 'directus_relations',
|
||||
icon: 'merge_type',
|
||||
note: 'Relationship configuration and metadata',
|
||||
},
|
||||
{
|
||||
collection: 'directus_revisions',
|
||||
note: 'Data snapshots for all activity',
|
||||
},
|
||||
{
|
||||
collection: 'directus_roles',
|
||||
icon: 'supervised_user_circle',
|
||||
note: 'Permission groups for system users',
|
||||
},
|
||||
{
|
||||
collection: 'directus_sessions',
|
||||
note: 'User session information',
|
||||
},
|
||||
{
|
||||
collection: 'directus_settings',
|
||||
singleton: true,
|
||||
note: 'Project configuration options',
|
||||
},
|
||||
{
|
||||
collection: 'directus_users',
|
||||
archive_field: 'status',
|
||||
archive_value: 'archived',
|
||||
unarchive_value: 'draft',
|
||||
icon: 'people_alt',
|
||||
note: 'System users for the platform',
|
||||
},
|
||||
{
|
||||
collection: 'directus_webhooks',
|
||||
note: 'Configuration for event-based HTTP requests',
|
||||
},
|
||||
];
|
||||
|
||||
await knex.insert(systemCollections).into('directus_collections');
|
||||
}
|
||||
1627
api/src/database/migrations/20201029C-remove-system-fields.ts
Normal file
1627
api/src/database/migrations/20201029C-remove-system-fields.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -7,9 +7,6 @@ columns:
|
||||
type: string
|
||||
length: 64
|
||||
nullable: false
|
||||
references:
|
||||
table: directus_collections
|
||||
column: collection
|
||||
field:
|
||||
type: string
|
||||
length: 64
|
||||
|
||||
@@ -25,9 +25,6 @@ columns:
|
||||
type: string
|
||||
length: 64
|
||||
nullable: false
|
||||
references:
|
||||
table: directus_collections
|
||||
column: collection
|
||||
item:
|
||||
type: string
|
||||
length: 255
|
||||
|
||||
@@ -12,9 +12,6 @@ columns:
|
||||
type: string
|
||||
length: 64
|
||||
nullable: false
|
||||
references:
|
||||
table: directus_collections
|
||||
column: collection
|
||||
action:
|
||||
type: string
|
||||
length: 10
|
||||
|
||||
@@ -19,9 +19,6 @@ columns:
|
||||
collection:
|
||||
type: string
|
||||
length: 64
|
||||
references:
|
||||
table: directus_collections
|
||||
column: collection
|
||||
search:
|
||||
type: string
|
||||
length: 100
|
||||
|
||||
@@ -7,9 +7,6 @@ columns:
|
||||
type: string
|
||||
length: 64
|
||||
nullable: false
|
||||
references:
|
||||
table: directus_collections
|
||||
column: collection
|
||||
many_field:
|
||||
type: string
|
||||
length: 64
|
||||
@@ -21,9 +18,6 @@ columns:
|
||||
one_collection:
|
||||
type: string
|
||||
length: 64
|
||||
references:
|
||||
table: directus_collections
|
||||
column: collection
|
||||
one_field:
|
||||
type: string
|
||||
length: 64
|
||||
|
||||
@@ -80,7 +80,7 @@ export class FieldsService {
|
||||
aliasQuery.andWhere('collection', collection);
|
||||
}
|
||||
|
||||
let aliasFields = await aliasQuery;
|
||||
let aliasFields = [...(await aliasQuery), ...systemFieldRows];
|
||||
|
||||
const aliasTypes = ['alias', 'o2m', 'm2m', 'files', 'files', 'translations'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user