directus

Форк
0
/
20201029B-remove-system-collections.ts 
99 строк · 2.3 Кб
1
import type { Knex } from 'knex';
2
import { merge } from 'lodash-es';
3

4
export async function up(knex: Knex): Promise<void> {
5
	await knex('directus_collections').delete().where('collection', 'like', 'directus_%');
6
}
7

8
export async function down(knex: Knex): Promise<void> {
9
	const defaults = {
10
		collection: null,
11
		hidden: false,
12
		singleton: false,
13
		icon: null,
14
		note: null,
15
		translations: null,
16
		display_template: null,
17
	};
18

19
	const systemCollections = [
20
		{
21
			collection: 'directus_activity',
22
			note: 'Accountability logs for all events',
23
		},
24
		{
25
			collection: 'directus_collections',
26
			icon: 'list_alt',
27
			note: 'Additional collection configuration and metadata',
28
		},
29
		{
30
			collection: 'directus_fields',
31
			icon: 'input',
32
			note: 'Additional field configuration and metadata',
33
		},
34
		{
35
			collection: 'directus_files',
36
			icon: 'folder',
37
			note: 'Metadata for all managed file assets',
38
		},
39
		{
40
			collection: 'directus_folders',
41
			note: 'Provides virtual directories for files',
42
		},
43
		{
44
			collection: 'directus_permissions',
45
			icon: 'admin_panel_settings',
46
			note: 'Access permissions for each role',
47
		},
48
		{
49
			collection: 'directus_presets',
50
			icon: 'bookmark_border',
51
			note: 'Presets for collection defaults and bookmarks',
52
		},
53
		{
54
			collection: 'directus_relations',
55
			icon: 'merge_type',
56
			note: 'Relationship configuration and metadata',
57
		},
58
		{
59
			collection: 'directus_revisions',
60
			note: 'Data snapshots for all activity',
61
		},
62
		{
63
			collection: 'directus_roles',
64
			icon: 'supervised_user_circle',
65
			note: 'Permission groups for system users',
66
		},
67
		{
68
			collection: 'directus_sessions',
69
			note: 'User session information',
70
		},
71
		{
72
			collection: 'directus_settings',
73
			singleton: true,
74
			note: 'Project configuration options',
75
		},
76
		{
77
			collection: 'directus_users',
78
			archive_field: 'status',
79
			archive_value: 'archived',
80
			unarchive_value: 'draft',
81
			icon: 'people_alt',
82
			note: 'System users for the platform',
83
		},
84
		{
85
			collection: 'directus_webhooks',
86
			note: 'Configuration for event-based HTTP requests',
87
		},
88
	].map((row) => {
89
		for (const [key, value] of Object.entries(row)) {
90
			if (value !== null && (typeof value === 'object' || Array.isArray(value))) {
91
				(row as any)[key] = JSON.stringify(value);
92
			}
93
		}
94

95
		return merge({}, defaults, row);
96
	});
97

98
	await knex.insert(systemCollections).into('directus_collections');
99
}
100

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.