directus 9.23.1 → 9.23.4
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.
- package/dist/app.js +25 -21
- package/dist/auth/auth.d.ts +3 -3
- package/dist/auth/auth.js +2 -0
- package/dist/auth/drivers/ldap.d.ts +1 -1
- package/dist/auth/drivers/ldap.js +57 -46
- package/dist/auth/drivers/local.d.ts +1 -1
- package/dist/auth/drivers/local.js +20 -17
- package/dist/auth/drivers/oauth2.d.ts +1 -1
- package/dist/auth/drivers/oauth2.js +44 -35
- package/dist/auth/drivers/openid.d.ts +1 -1
- package/dist/auth/drivers/openid.js +50 -41
- package/dist/auth/drivers/saml.d.ts +1 -1
- package/dist/auth/drivers/saml.js +20 -17
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +8 -7
- package/dist/cache.d.ts +9 -1
- package/dist/cache.js +66 -18
- package/dist/cli/commands/bootstrap/index.js +7 -6
- package/dist/cli/commands/init/index.js +3 -3
- package/dist/cli/commands/schema/apply.js +14 -15
- package/dist/cli/commands/schema/snapshot.js +2 -2
- package/dist/cli/utils/create-db-connection.d.ts +1 -1
- package/dist/cli/utils/create-db-connection.js +3 -2
- package/dist/cli/utils/create-env/index.d.ts +2 -2
- package/dist/cli/utils/create-env/index.js +1 -1
- package/dist/cli/utils/drivers.d.ts +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +7 -7
- package/dist/controllers/activity.js +10 -11
- package/dist/controllers/assets.js +31 -25
- package/dist/controllers/auth.js +40 -26
- package/dist/controllers/collections.js +10 -10
- package/dist/controllers/dashboards.js +14 -11
- package/dist/controllers/extensions.js +3 -3
- package/dist/controllers/fields.js +20 -20
- package/dist/controllers/files.js +26 -20
- package/dist/controllers/flows.js +16 -13
- package/dist/controllers/folders.js +14 -11
- package/dist/controllers/graphql.js +6 -8
- package/dist/controllers/items.js +22 -19
- package/dist/controllers/not-found.d.ts +1 -1
- package/dist/controllers/not-found.js +1 -2
- package/dist/controllers/notifications.js +14 -11
- package/dist/controllers/operations.js +14 -11
- package/dist/controllers/panels.js +14 -11
- package/dist/controllers/permissions.js +14 -11
- package/dist/controllers/presets.js +14 -11
- package/dist/controllers/relations.js +10 -10
- package/dist/controllers/revisions.js +3 -3
- package/dist/controllers/roles.js +14 -11
- package/dist/controllers/schema.js +5 -5
- package/dist/controllers/server.js +7 -7
- package/dist/controllers/settings.js +2 -2
- package/dist/controllers/shares.js +21 -18
- package/dist/controllers/users.js +32 -36
- package/dist/controllers/utils.js +10 -15
- package/dist/controllers/webhooks.js +14 -11
- package/dist/database/helpers/fn/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/mssql.js +10 -11
- package/dist/database/helpers/fn/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/mysql.js +2 -3
- package/dist/database/helpers/fn/dialects/oracle.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/oracle.js +10 -11
- package/dist/database/helpers/fn/dialects/postgres.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/postgres.js +10 -11
- package/dist/database/helpers/fn/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/sqlite.js +10 -11
- package/dist/database/helpers/fn/types.d.ts +5 -6
- package/dist/database/helpers/fn/types.js +4 -5
- package/dist/database/helpers/geometry/dialects/mssql.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/geometry/dialects/oracle.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/postgres.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/postgres.js +1 -2
- package/dist/database/helpers/geometry/dialects/redshift.d.ts +2 -2
- package/dist/database/helpers/geometry/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/geometry/types.d.ts +2 -2
- package/dist/database/helpers/geometry/types.js +1 -2
- package/dist/database/helpers/index.d.ts +5 -5
- package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.js +1 -2
- package/dist/database/helpers/schema/dialects/oracle.d.ts +2 -2
- package/dist/database/helpers/schema/dialects/oracle.js +4 -6
- package/dist/database/helpers/schema/types.d.ts +4 -4
- package/dist/database/helpers/types.d.ts +1 -1
- package/dist/database/helpers/types.js +1 -0
- package/dist/database/index.d.ts +1 -1
- package/dist/database/index.js +13 -13
- package/dist/database/migrations/20201028A-remove-collection-foreign-keys.d.ts +1 -1
- package/dist/database/migrations/20201029A-remove-system-relations.d.ts +1 -1
- package/dist/database/migrations/20201029B-remove-system-collections.d.ts +1 -1
- package/dist/database/migrations/20201029C-remove-system-fields.d.ts +1 -1
- package/dist/database/migrations/20201105A-add-cascade-system-relations.d.ts +1 -1
- package/dist/database/migrations/20201105B-change-webhook-url-type.d.ts +1 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.d.ts +1 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.js +1 -2
- package/dist/database/migrations/20210304A-remove-locked-fields.d.ts +1 -1
- package/dist/database/migrations/20210312A-webhooks-collections-text.d.ts +1 -1
- package/dist/database/migrations/20210331A-add-refresh-interval.d.ts +1 -1
- package/dist/database/migrations/20210415A-make-filesize-nullable.d.ts +1 -1
- package/dist/database/migrations/20210416A-add-collections-accountability.d.ts +1 -1
- package/dist/database/migrations/20210422A-remove-files-interface.d.ts +1 -1
- package/dist/database/migrations/20210506A-rename-interfaces.d.ts +1 -1
- package/dist/database/migrations/20210510A-restructure-relations.d.ts +1 -1
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.d.ts +1 -1
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.d.ts +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.js +2 -2
- package/dist/database/migrations/20210521A-add-collections-icon-color.d.ts +1 -1
- package/dist/database/migrations/20210525A-add-insights.d.ts +1 -1
- package/dist/database/migrations/20210608A-add-deep-clone-config.d.ts +1 -1
- package/dist/database/migrations/20210626A-change-filesize-bigint.d.ts +1 -1
- package/dist/database/migrations/20210716A-add-conditions-to-fields.d.ts +1 -1
- package/dist/database/migrations/20210721A-add-default-folder.d.ts +1 -1
- package/dist/database/migrations/20210802A-replace-groups.d.ts +1 -1
- package/dist/database/migrations/20210803A-add-required-to-fields.d.ts +1 -1
- package/dist/database/migrations/20210805A-update-groups.d.ts +1 -1
- package/dist/database/migrations/20210805B-change-image-metadata-structure.d.ts +1 -1
- package/dist/database/migrations/20210805B-change-image-metadata-structure.js +15 -15
- package/dist/database/migrations/20210811A-add-geometry-config.d.ts +1 -1
- package/dist/database/migrations/20210831A-remove-limit-column.d.ts +1 -1
- package/dist/database/migrations/20210903A-add-auth-provider.d.ts +1 -1
- package/dist/database/migrations/20210907A-webhooks-collections-not-null.d.ts +1 -1
- package/dist/database/migrations/20210910A-move-module-setup.d.ts +1 -1
- package/dist/database/migrations/20210920A-webhooks-url-not-null.d.ts +1 -1
- package/dist/database/migrations/20210924A-add-collection-organization.d.ts +1 -1
- package/dist/database/migrations/20210927A-replace-fields-group.d.ts +1 -1
- package/dist/database/migrations/20210927B-replace-m2m-interface.d.ts +1 -1
- package/dist/database/migrations/20210929A-rename-login-action.d.ts +1 -1
- package/dist/database/migrations/20211007A-update-presets.d.ts +1 -1
- package/dist/database/migrations/20211007A-update-presets.js +7 -9
- package/dist/database/migrations/20211009A-add-auth-data.d.ts +1 -1
- package/dist/database/migrations/20211016A-add-webhook-headers.d.ts +1 -1
- package/dist/database/migrations/20211103A-set-unique-to-user-token.d.ts +1 -1
- package/dist/database/migrations/20211103B-update-special-geometry.d.ts +1 -1
- package/dist/database/migrations/20211104A-remove-collections-listing.d.ts +1 -1
- package/dist/database/migrations/20211118A-add-notifications.d.ts +1 -1
- package/dist/database/migrations/20211211A-add-shares.d.ts +1 -1
- package/dist/database/migrations/20211230A-add-project-descriptor.d.ts +1 -1
- package/dist/database/migrations/20220303A-remove-default-project-color.d.ts +1 -1
- package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.d.ts +1 -1
- package/dist/database/migrations/20220314A-add-translation-strings.d.ts +1 -1
- package/dist/database/migrations/20220322A-rename-field-typecast-flags.d.ts +1 -1
- package/dist/database/migrations/20220323A-add-field-validation.d.ts +1 -1
- package/dist/database/migrations/20220325A-fix-typecast-flags.d.ts +1 -1
- package/dist/database/migrations/20220325B-add-default-language.d.ts +1 -1
- package/dist/database/migrations/20220402A-remove-default-value-panel-icon.d.ts +1 -1
- package/dist/database/migrations/20220429A-add-flows.d.ts +1 -1
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.d.ts +1 -1
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.d.ts +1 -1
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.d.ts +1 -1
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.d.ts +1 -1
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.d.ts +1 -1
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.d.ts +1 -1
- package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +1 -1
- package/dist/database/migrations/run.d.ts +1 -1
- package/dist/database/migrations/run.js +1 -1
- package/dist/database/run-ast.d.ts +3 -3
- package/dist/database/run-ast.js +21 -30
- package/dist/database/seeds/run.d.ts +1 -1
- package/dist/database/seeds/run.js +1 -2
- package/dist/database/system-data/app-access-permissions/index.d.ts +1 -1
- package/dist/database/system-data/collections/index.d.ts +1 -1
- package/dist/database/system-data/collections/index.js +2 -2
- package/dist/database/system-data/fields/collections.yaml +2 -0
- package/dist/database/system-data/fields/index.d.ts +1 -1
- package/dist/database/system-data/fields/index.js +3 -4
- package/dist/database/system-data/fields/settings.yaml +4 -0
- package/dist/database/system-data/relations/index.d.ts +1 -1
- package/dist/emitter.d.ts +1 -1
- package/dist/emitter.js +3 -0
- package/dist/env.js +11 -3
- package/dist/exceptions/database/dialects/mssql.d.ts +1 -1
- package/dist/exceptions/database/dialects/mssql.js +5 -6
- package/dist/exceptions/database/dialects/mysql.d.ts +1 -1
- package/dist/exceptions/database/dialects/mysql.js +19 -25
- package/dist/exceptions/database/dialects/oracle.d.ts +1 -1
- package/dist/exceptions/database/dialects/postgres.d.ts +1 -1
- package/dist/exceptions/database/dialects/sqlite.d.ts +1 -1
- package/dist/exceptions/database/translate.d.ts +1 -1
- package/dist/exceptions/database/value-out-of-range.js +1 -1
- package/dist/exceptions/range-not-satisfiable.js +2 -3
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +43 -33
- package/dist/flows.js +65 -46
- package/dist/logger.d.ts +2 -1
- package/dist/logger.js +35 -19
- package/dist/logger.test.d.ts +1 -0
- package/dist/mailer.js +16 -16
- package/dist/messenger.js +9 -7
- package/dist/middleware/authenticate.d.ts +1 -1
- package/dist/middleware/authenticate.js +13 -6
- package/dist/middleware/cache.d.ts +1 -1
- package/dist/middleware/cache.js +16 -16
- package/dist/middleware/check-ip.d.ts +1 -1
- package/dist/middleware/check-ip.js +1 -1
- package/dist/middleware/collection-exists.d.ts +1 -1
- package/dist/middleware/collection-exists.js +5 -5
- package/dist/middleware/cors.d.ts +1 -1
- package/dist/middleware/cors.js +7 -7
- package/dist/middleware/error-handler.d.ts +1 -1
- package/dist/middleware/error-handler.js +11 -12
- package/dist/middleware/extract-token.d.ts +1 -1
- package/dist/middleware/extract-token.js +2 -2
- package/dist/middleware/get-permissions.d.ts +1 -1
- package/dist/middleware/graphql.d.ts +1 -1
- package/dist/middleware/graphql.js +15 -9
- package/dist/middleware/rate-limiter-global.d.ts +5 -0
- package/dist/middleware/rate-limiter-global.js +48 -0
- package/dist/middleware/{rate-limiter.d.ts → rate-limiter-ip.d.ts} +2 -2
- package/dist/middleware/{rate-limiter.js → rate-limiter-ip.js} +5 -5
- package/dist/middleware/respond.d.ts +1 -1
- package/dist/middleware/respond.js +18 -19
- package/dist/middleware/sanitize-query.d.ts +1 -1
- package/dist/middleware/sanitize-query.js +1 -1
- package/dist/middleware/schema.d.ts +1 -1
- package/dist/middleware/use-collection.d.ts +1 -1
- package/dist/operations/condition/index.d.ts +1 -1
- package/dist/operations/exec/index.js +15 -4
- package/dist/operations/item-create/index.js +1 -2
- package/dist/operations/item-delete/index.d.ts +1 -1
- package/dist/operations/item-read/index.d.ts +1 -1
- package/dist/operations/item-update/index.d.ts +1 -1
- package/dist/operations/item-update/index.js +1 -2
- package/dist/operations/notification/index.js +1 -2
- package/dist/operations/request/index.js +19 -19
- package/dist/operations/trigger/index.js +2 -3
- package/dist/rate-limiter.d.ts +1 -1
- package/dist/rate-limiter.js +9 -9
- package/dist/request/validate-ip.js +2 -2
- package/dist/server.js +12 -13
- package/dist/services/activity.d.ts +1 -1
- package/dist/services/activity.js +17 -16
- package/dist/services/assets.d.ts +3 -3
- package/dist/services/assets.js +35 -37
- package/dist/services/authentication.d.ts +2 -2
- package/dist/services/authentication.js +22 -19
- package/dist/services/authorization.d.ts +3 -3
- package/dist/services/authorization.js +27 -31
- package/dist/services/collections.d.ts +5 -5
- package/dist/services/collections.js +54 -50
- package/dist/services/dashboards.d.ts +1 -1
- package/dist/services/fields.d.ts +5 -5
- package/dist/services/fields.js +50 -50
- package/dist/services/files.d.ts +1 -2
- package/dist/services/files.js +33 -27
- package/dist/services/flows.d.ts +2 -2
- package/dist/services/folders.d.ts +1 -1
- package/dist/services/graphql/index.d.ts +4 -4
- package/dist/services/graphql/index.js +259 -252
- package/dist/services/graphql/utils/add-path-to-validation-error.js +1 -2
- package/dist/services/graphql/utils/process-error.d.ts +2 -2
- package/dist/services/graphql/utils/process-error.js +11 -4
- package/dist/services/import-export.d.ts +3 -3
- package/dist/services/import-export.js +30 -27
- package/dist/services/items.d.ts +3 -3
- package/dist/services/items.js +42 -36
- package/dist/services/mail/index.d.ts +4 -4
- package/dist/services/mail/index.js +14 -10
- package/dist/services/meta.d.ts +3 -3
- package/dist/services/meta.js +11 -9
- package/dist/services/notifications.d.ts +3 -3
- package/dist/services/notifications.js +10 -9
- package/dist/services/operations.d.ts +2 -2
- package/dist/services/panels.d.ts +1 -1
- package/dist/services/payload.d.ts +3 -3
- package/dist/services/payload.js +124 -122
- package/dist/services/permissions.d.ts +3 -3
- package/dist/services/permissions.js +11 -11
- package/dist/services/presets.d.ts +1 -1
- package/dist/services/relations.d.ts +6 -6
- package/dist/services/relations.js +45 -43
- package/dist/services/revisions.d.ts +1 -1
- package/dist/services/revisions.js +3 -3
- package/dist/services/roles.d.ts +2 -2
- package/dist/services/roles.js +7 -7
- package/dist/services/schema.d.ts +3 -3
- package/dist/services/schema.js +9 -11
- package/dist/services/server.d.ts +3 -3
- package/dist/services/server.js +88 -32
- package/dist/services/settings.d.ts +1 -1
- package/dist/services/shares.d.ts +1 -1
- package/dist/services/shares.js +14 -15
- package/dist/services/specifications.d.ts +4 -4
- package/dist/services/specifications.js +137 -119
- package/dist/services/tfa.d.ts +2 -2
- package/dist/services/tfa.js +7 -5
- package/dist/services/users.d.ts +2 -6
- package/dist/services/users.js +37 -40
- package/dist/services/utils.d.ts +3 -3
- package/dist/services/utils.js +10 -8
- package/dist/services/webhooks.d.ts +2 -2
- package/dist/services/webhooks.js +2 -1
- package/dist/storage/register-locations.js +1 -1
- package/dist/types/assets.d.ts +1 -1
- package/dist/types/ast.d.ts +1 -1
- package/dist/types/auth.d.ts +2 -2
- package/dist/types/collection.d.ts +2 -2
- package/dist/types/events.d.ts +2 -2
- package/dist/types/graphql.d.ts +2 -2
- package/dist/types/items.d.ts +3 -3
- package/dist/types/services.d.ts +5 -5
- package/dist/types/snapshot.d.ts +4 -4
- package/dist/utils/apply-diff.d.ts +3 -3
- package/dist/utils/apply-diff.js +25 -28
- package/dist/utils/apply-query.d.ts +3 -3
- package/dist/utils/apply-query.js +10 -12
- package/dist/utils/apply-snapshot.d.ts +3 -3
- package/dist/utils/apply-snapshot.js +5 -6
- package/dist/utils/construct-flow-tree.d.ts +1 -1
- package/dist/utils/construct-flow-tree.js +2 -2
- package/dist/utils/dynamic-import.js +1 -1
- package/dist/utils/filter-items.d.ts +1 -1
- package/dist/utils/generate-hash.js +1 -1
- package/dist/utils/get-accountability-for-role.d.ts +2 -2
- package/dist/utils/get-accountability-for-role.js +1 -1
- package/dist/utils/get-ast-from-query.d.ts +3 -3
- package/dist/utils/get-ast-from-query.js +22 -28
- package/dist/utils/get-auth-providers.js +1 -1
- package/dist/utils/get-cache-headers.d.ts +1 -1
- package/dist/utils/get-cache-headers.js +6 -7
- package/dist/utils/get-cache-key.d.ts +1 -1
- package/dist/utils/get-cache-key.js +2 -3
- package/dist/utils/get-collection-from-alias.d.ts +1 -1
- package/dist/utils/get-collection-from-alias.js +1 -0
- package/dist/utils/get-column-path.d.ts +2 -2
- package/dist/utils/get-column-path.js +3 -4
- package/dist/utils/get-column.d.ts +4 -4
- package/dist/utils/get-column.js +4 -5
- package/dist/utils/get-default-value.d.ts +2 -2
- package/dist/utils/get-default-value.js +2 -3
- package/dist/utils/get-graphql-query-and-variables.d.ts +1 -1
- package/dist/utils/get-graphql-query-and-variables.js +1 -2
- package/dist/utils/get-graphql-type.d.ts +2 -2
- package/dist/utils/get-graphql-type.js +1 -1
- package/dist/utils/get-ip-from-req.d.ts +1 -1
- package/dist/utils/get-ip-from-req.js +2 -2
- package/dist/utils/get-local-type.d.ts +1 -1
- package/dist/utils/get-local-type.js +3 -3
- package/dist/utils/get-milliseconds.js +1 -2
- package/dist/utils/get-permissions.d.ts +1 -1
- package/dist/utils/get-permissions.js +12 -12
- package/dist/utils/get-relation-info.d.ts +1 -1
- package/dist/utils/get-relation-info.js +3 -5
- package/dist/utils/get-relation-type.d.ts +1 -1
- package/dist/utils/get-relation-type.js +3 -4
- package/dist/utils/get-schema.d.ts +2 -2
- package/dist/utils/get-schema.js +20 -22
- package/dist/utils/get-snapshot-diff.js +2 -3
- package/dist/utils/get-snapshot.d.ts +3 -3
- package/dist/utils/get-snapshot.js +6 -8
- package/dist/utils/is-directus-jwt.js +1 -1
- package/dist/utils/is-url-allowed.js +5 -2
- package/dist/utils/job-queue.js +2 -0
- package/dist/utils/jwt.d.ts +1 -1
- package/dist/utils/merge-permissions-for-share.d.ts +1 -1
- package/dist/utils/merge-permissions-for-share.js +3 -4
- package/dist/utils/merge-permissions.d.ts +3 -3
- package/dist/utils/reduce-schema.d.ts +1 -1
- package/dist/utils/reduce-schema.js +12 -12
- package/dist/utils/sanitize-query.d.ts +1 -1
- package/dist/utils/sanitize-query.js +27 -27
- package/dist/utils/sanitize-schema.d.ts +2 -2
- package/dist/utils/should-skip-cache.d.ts +7 -0
- package/dist/utils/should-skip-cache.js +21 -0
- package/dist/utils/should-skip-cache.test.d.ts +1 -0
- package/dist/utils/track.js +16 -16
- package/dist/utils/transformations.d.ts +1 -1
- package/dist/utils/transformations.js +2 -4
- package/dist/utils/url.js +7 -2
- package/dist/utils/user-name.d.ts +1 -1
- package/dist/utils/validate-diff.js +7 -8
- package/dist/utils/validate-keys.d.ts +2 -2
- package/dist/utils/validate-keys.js +1 -1
- package/dist/utils/validate-query.d.ts +1 -1
- package/dist/utils/validate-query.js +3 -3
- package/dist/utils/validate-storage.js +8 -8
- package/dist/webhooks.js +3 -3
- package/package.json +36 -37
- package/dist/utils/with-timeout.d.ts +0 -1
- package/dist/utils/with-timeout.js +0 -16
|
@@ -10,57 +10,56 @@ const parseLocaltime = (columnType) => {
|
|
|
10
10
|
};
|
|
11
11
|
class FnHelperSQLite extends types_1.FnHelper {
|
|
12
12
|
year(table, column, options) {
|
|
13
|
-
return this.knex.raw(`CAST(strftime('%Y', ??.?? / 1000, 'unixepoch'${parseLocaltime(options
|
|
13
|
+
return this.knex.raw(`CAST(strftime('%Y', ??.?? / 1000, 'unixepoch'${parseLocaltime(options?.type)}) AS INTEGER)`, [
|
|
14
14
|
table,
|
|
15
15
|
column,
|
|
16
16
|
]);
|
|
17
17
|
}
|
|
18
18
|
month(table, column, options) {
|
|
19
|
-
return this.knex.raw(`CAST(strftime('%m', ??.?? / 1000, 'unixepoch'${parseLocaltime(options
|
|
19
|
+
return this.knex.raw(`CAST(strftime('%m', ??.?? / 1000, 'unixepoch'${parseLocaltime(options?.type)}) AS INTEGER)`, [
|
|
20
20
|
table,
|
|
21
21
|
column,
|
|
22
22
|
]);
|
|
23
23
|
}
|
|
24
24
|
week(table, column, options) {
|
|
25
|
-
return this.knex.raw(`CAST(strftime('%W', ??.?? / 1000, 'unixepoch'${parseLocaltime(options
|
|
25
|
+
return this.knex.raw(`CAST(strftime('%W', ??.?? / 1000, 'unixepoch'${parseLocaltime(options?.type)}) AS INTEGER)`, [
|
|
26
26
|
table,
|
|
27
27
|
column,
|
|
28
28
|
]);
|
|
29
29
|
}
|
|
30
30
|
day(table, column, options) {
|
|
31
|
-
return this.knex.raw(`CAST(strftime('%d', ??.?? / 1000, 'unixepoch'${parseLocaltime(options
|
|
31
|
+
return this.knex.raw(`CAST(strftime('%d', ??.?? / 1000, 'unixepoch'${parseLocaltime(options?.type)}) AS INTEGER)`, [
|
|
32
32
|
table,
|
|
33
33
|
column,
|
|
34
34
|
]);
|
|
35
35
|
}
|
|
36
36
|
weekday(table, column, options) {
|
|
37
|
-
return this.knex.raw(`CAST(strftime('%w', ??.?? / 1000, 'unixepoch'${parseLocaltime(options
|
|
37
|
+
return this.knex.raw(`CAST(strftime('%w', ??.?? / 1000, 'unixepoch'${parseLocaltime(options?.type)}) AS INTEGER)`, [
|
|
38
38
|
table,
|
|
39
39
|
column,
|
|
40
40
|
]);
|
|
41
41
|
}
|
|
42
42
|
hour(table, column, options) {
|
|
43
|
-
return this.knex.raw(`CAST(strftime('%H', ??.?? / 1000, 'unixepoch'${parseLocaltime(options
|
|
43
|
+
return this.knex.raw(`CAST(strftime('%H', ??.?? / 1000, 'unixepoch'${parseLocaltime(options?.type)}) AS INTEGER)`, [
|
|
44
44
|
table,
|
|
45
45
|
column,
|
|
46
46
|
]);
|
|
47
47
|
}
|
|
48
48
|
minute(table, column, options) {
|
|
49
|
-
return this.knex.raw(`CAST(strftime('%M', ??.?? / 1000, 'unixepoch'${parseLocaltime(options
|
|
49
|
+
return this.knex.raw(`CAST(strftime('%M', ??.?? / 1000, 'unixepoch'${parseLocaltime(options?.type)}) AS INTEGER)`, [
|
|
50
50
|
table,
|
|
51
51
|
column,
|
|
52
52
|
]);
|
|
53
53
|
}
|
|
54
54
|
second(table, column, options) {
|
|
55
|
-
return this.knex.raw(`CAST(strftime('%S', ??.?? / 1000, 'unixepoch'${parseLocaltime(options
|
|
55
|
+
return this.knex.raw(`CAST(strftime('%S', ??.?? / 1000, 'unixepoch'${parseLocaltime(options?.type)}) AS INTEGER)`, [
|
|
56
56
|
table,
|
|
57
57
|
column,
|
|
58
58
|
]);
|
|
59
59
|
}
|
|
60
60
|
count(table, column, options) {
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const type = (_e = (_d = (_c = (_b = (_a = this.schema.collections) === null || _a === void 0 ? void 0 : _a[collectionName]) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c[column]) === null || _d === void 0 ? void 0 : _d.type) !== null && _e !== void 0 ? _e : 'unknown';
|
|
61
|
+
const collectionName = options?.originalCollectionName || table;
|
|
62
|
+
const type = this.schema.collections?.[collectionName]?.fields?.[column]?.type ?? 'unknown';
|
|
64
63
|
if (type === 'json') {
|
|
65
64
|
return this.knex.raw(`json_array_length(??.??, '$')`, [table, column]);
|
|
66
65
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { Query, SchemaOverview } from '@directus/shared/types';
|
|
2
|
-
import { Knex } from 'knex';
|
|
1
|
+
import type { Query, SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
3
|
import { DatabaseHelper } from '../types';
|
|
4
4
|
export type FnHelperOptions = {
|
|
5
|
-
type
|
|
6
|
-
query
|
|
7
|
-
originalCollectionName
|
|
5
|
+
type: string | undefined;
|
|
6
|
+
query: Query | undefined;
|
|
7
|
+
originalCollectionName: string | undefined;
|
|
8
8
|
};
|
|
9
9
|
export declare abstract class FnHelper extends DatabaseHelper {
|
|
10
|
-
protected knex: Knex;
|
|
11
10
|
protected schema: SchemaOverview;
|
|
12
11
|
constructor(knex: Knex, schema: SchemaOverview);
|
|
13
12
|
abstract year(table: string, column: string, options?: FnHelperOptions): Knex.Raw;
|
|
@@ -4,16 +4,15 @@ exports.FnHelper = void 0;
|
|
|
4
4
|
const apply_query_1 = require("../../../utils/apply-query");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
class FnHelper extends types_1.DatabaseHelper {
|
|
7
|
+
schema;
|
|
7
8
|
constructor(knex, schema) {
|
|
8
9
|
super(knex);
|
|
9
|
-
this.knex = knex;
|
|
10
10
|
this.schema = schema;
|
|
11
11
|
this.schema = schema;
|
|
12
12
|
}
|
|
13
13
|
_relationalCount(table, column, options) {
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const relation = this.schema.relations.find((relation) => { var _a; return relation.related_collection === collectionName && ((_a = relation === null || relation === void 0 ? void 0 : relation.meta) === null || _a === void 0 ? void 0 : _a.one_field) === column; });
|
|
14
|
+
const collectionName = options?.originalCollectionName || table;
|
|
15
|
+
const relation = this.schema.relations.find((relation) => relation.related_collection === collectionName && relation?.meta?.one_field === column);
|
|
17
16
|
const currentPrimary = this.schema.collections[collectionName].primary;
|
|
18
17
|
if (!relation) {
|
|
19
18
|
throw new Error(`Field ${collectionName}.${column} isn't a nested relational collection`);
|
|
@@ -22,7 +21,7 @@ class FnHelper extends types_1.DatabaseHelper {
|
|
|
22
21
|
.count('*')
|
|
23
22
|
.from(relation.collection)
|
|
24
23
|
.where(relation.field, '=', this.knex.raw(`??.??`, [table, currentPrimary]));
|
|
25
|
-
if (
|
|
24
|
+
if (options?.query?.filter) {
|
|
26
25
|
countQuery = (0, apply_query_1.applyFilter)(this.knex, this.schema, countQuery, options.query.filter, relation.collection, {}).query;
|
|
27
26
|
}
|
|
28
27
|
return this.knex.raw('(' + countQuery.toQuery() + ')');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Field, RawField } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { GeoJSONGeometry } from 'wellknown';
|
|
1
4
|
import { GeometryHelper } from '../types';
|
|
2
|
-
import { Field, RawField } from '@directus/shared/types';
|
|
3
|
-
import { GeoJSONGeometry } from 'wellknown';
|
|
4
|
-
import { Knex } from 'knex';
|
|
5
5
|
export declare class GeometryHelperMSSQL extends GeometryHelper {
|
|
6
6
|
isTrue(expression: Knex.Raw): Knex.Raw<any>;
|
|
7
7
|
isFalse(expression: Knex.Raw): Knex.Raw<any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Field, RawField } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { GeoJSONGeometry } from 'wellknown';
|
|
1
4
|
import { GeometryHelper } from '../types';
|
|
2
|
-
import { Field, RawField } from '@directus/shared/types';
|
|
3
|
-
import { GeoJSONGeometry } from 'wellknown';
|
|
4
|
-
import { Knex } from 'knex';
|
|
5
5
|
export declare class GeometryHelperOracle extends GeometryHelper {
|
|
6
6
|
isTrue(expression: Knex.Raw): Knex.Raw<any>;
|
|
7
7
|
isFalse(expression: Knex.Raw): Knex.Raw<any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Field, RawField } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { GeoJSONGeometry } from 'wellknown';
|
|
1
4
|
import { GeometryHelper } from '../types';
|
|
2
|
-
import { Field, RawField } from '@directus/shared/types';
|
|
3
|
-
import { GeoJSONGeometry } from 'wellknown';
|
|
4
|
-
import { Knex } from 'knex';
|
|
5
5
|
export declare class GeometryHelperPostgres extends GeometryHelper {
|
|
6
6
|
supported(): Promise<boolean>;
|
|
7
7
|
createColumn(table: Knex.CreateTableBuilder, field: RawField | Field): Knex.ColumnBuilder;
|
|
@@ -8,8 +8,7 @@ class GeometryHelperPostgres extends types_1.GeometryHelper {
|
|
|
8
8
|
return res.length > 0;
|
|
9
9
|
}
|
|
10
10
|
createColumn(table, field) {
|
|
11
|
-
|
|
12
|
-
const type = (_a = field.type.split('.')[1]) !== null && _a !== void 0 ? _a : 'geometry';
|
|
11
|
+
const type = field.type.split('.')[1] ?? 'geometry';
|
|
13
12
|
return table.specificType(field.field, `geometry(${type}, 4326)`);
|
|
14
13
|
}
|
|
15
14
|
_intersects_bbox(key, geojson) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Field, RawField } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
1
3
|
import { GeometryHelper } from '../types';
|
|
2
|
-
import { Field, RawField } from '@directus/shared/types';
|
|
3
|
-
import { Knex } from 'knex';
|
|
4
4
|
export declare class GeometryHelperRedshift extends GeometryHelper {
|
|
5
5
|
createColumn(table: Knex.CreateTableBuilder, field: RawField | Field): Knex.ColumnBuilder;
|
|
6
6
|
asGeoJSON(table: string, column: string): Knex.Raw;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Field, RawField } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
1
3
|
import { GeoJSONGeometry } from 'wellknown';
|
|
2
|
-
import { Field, RawField } from '@directus/shared/types';
|
|
3
4
|
import { DatabaseHelper } from '../types';
|
|
4
|
-
import { Knex } from 'knex';
|
|
5
5
|
export declare abstract class GeometryHelper extends DatabaseHelper {
|
|
6
6
|
supported(): boolean | Promise<boolean>;
|
|
7
7
|
isTrue(expression: Knex.Raw): Knex.Raw<any>;
|
|
@@ -14,8 +14,7 @@ class GeometryHelper extends types_1.DatabaseHelper {
|
|
|
14
14
|
return expression.wrap('NOT ', '');
|
|
15
15
|
}
|
|
16
16
|
createColumn(table, field) {
|
|
17
|
-
|
|
18
|
-
const type = (_a = field.type.split('.')[1]) !== null && _a !== void 0 ? _a : 'geometry';
|
|
17
|
+
const type = field.type.split('.')[1] ?? 'geometry';
|
|
19
18
|
return table.specificType(field.field, type);
|
|
20
19
|
}
|
|
21
20
|
asText(table, column) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { SchemaOverview } from '@directus/shared/types';
|
|
2
|
-
import { Knex } from 'knex';
|
|
1
|
+
import type { SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
3
|
import * as dateHelpers from './date';
|
|
4
4
|
import * as fnHelpers from './fn';
|
|
5
5
|
import * as geometryHelpers from './geometry';
|
|
6
6
|
import * as schemaHelpers from './schema';
|
|
7
7
|
export declare function getHelpers(database: Knex): {
|
|
8
8
|
date: dateHelpers.postgres | dateHelpers.oracle | dateHelpers.mysql | dateHelpers.mssql | dateHelpers.sqlite;
|
|
9
|
-
st: geometryHelpers.
|
|
10
|
-
schema: schemaHelpers.
|
|
9
|
+
st: geometryHelpers.mysql | geometryHelpers.postgres | geometryHelpers.mssql | geometryHelpers.sqlite | geometryHelpers.oracle | geometryHelpers.redshift;
|
|
10
|
+
schema: schemaHelpers.mysql | schemaHelpers.cockroachdb | schemaHelpers.mssql | schemaHelpers.postgres | schemaHelpers.sqlite | schemaHelpers.oracle;
|
|
11
11
|
};
|
|
12
|
-
export declare function getFunctions(database: Knex, schema: SchemaOverview): fnHelpers.
|
|
12
|
+
export declare function getFunctions(database: Knex, schema: SchemaOverview): fnHelpers.mysql | fnHelpers.postgres | fnHelpers.mssql | fnHelpers.sqlite | fnHelpers.oracle;
|
|
13
13
|
export type Helpers = ReturnType<typeof getHelpers>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KNEX_TYPES } from '@directus/shared/constants';
|
|
1
|
+
import type { KNEX_TYPES } from '@directus/shared/constants';
|
|
2
2
|
import { Options, SchemaHelper } from '../types';
|
|
3
3
|
export declare class SchemaHelperCockroachDb extends SchemaHelper {
|
|
4
4
|
changeToType(table: string, column: string, type: (typeof KNEX_TYPES)[number], options?: Options): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Knex } from 'knex';
|
|
1
|
+
import type { Knex } from 'knex';
|
|
2
2
|
import { SchemaHelper } from '../types';
|
|
3
3
|
export declare class SchemaHelperMySQL extends SchemaHelper {
|
|
4
4
|
applyMultiRelationalSort(knex: Knex, dbQuery: Knex.QueryBuilder, table: string, primaryKey: string, orderByString: string, orderByFields: Knex.Raw[]): Knex.QueryBuilder;
|
|
@@ -5,8 +5,7 @@ const database_1 = require("../../../../database");
|
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
class SchemaHelperMySQL extends types_1.SchemaHelper {
|
|
7
7
|
applyMultiRelationalSort(knex, dbQuery, table, primaryKey, orderByString, orderByFields) {
|
|
8
|
-
|
|
9
|
-
if ((_a = (0, database_1.getDatabaseVersion)()) === null || _a === void 0 ? void 0 : _a.startsWith('5.7')) {
|
|
8
|
+
if ((0, database_1.getDatabaseVersion)()?.startsWith('5.7')) {
|
|
10
9
|
dbQuery.orderByRaw(`?? asc, ${orderByString}`, [`${table}.${primaryKey}`, ...orderByFields]);
|
|
11
10
|
dbQuery = knex
|
|
12
11
|
.select(knex.raw(`??, ( @rank := IF ( @cur_id = deep.${primaryKey}, @rank + 1, 1 ) ) AS directus_row_number, ( @cur_id := deep.${primaryKey} ) AS current_id`, 'deep.*'))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { KNEX_TYPES } from '@directus/shared/constants';
|
|
2
|
-
import { Field, Relation, Type } from '@directus/shared/types';
|
|
1
|
+
import type { KNEX_TYPES } from '@directus/shared/constants';
|
|
2
|
+
import type { Field, Relation, Type } from '@directus/shared/types';
|
|
3
3
|
import { Options, SchemaHelper } from '../types';
|
|
4
4
|
export declare class SchemaHelperOracle extends SchemaHelper {
|
|
5
5
|
changeToType(table: string, column: string, type: (typeof KNEX_TYPES)[number], options?: Options): Promise<void>;
|
|
@@ -10,25 +10,23 @@ class SchemaHelperOracle extends types_1.SchemaHelper {
|
|
|
10
10
|
return 'CAST(?? AS VARCHAR2(255))';
|
|
11
11
|
}
|
|
12
12
|
preRelationChange(relation) {
|
|
13
|
-
var _a;
|
|
14
13
|
if (relation.collection === relation.related_collection) {
|
|
15
14
|
// Constraints are not allowed on self referencing relationships
|
|
16
15
|
// Setting NO ACTION throws - ORA-00905: missing keyword
|
|
17
|
-
if (
|
|
16
|
+
if (relation.schema?.on_delete) {
|
|
18
17
|
relation.schema.on_delete = null;
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
processFieldType(field) {
|
|
23
|
-
var _a, _b, _c, _d;
|
|
24
22
|
if (field.type === 'integer') {
|
|
25
|
-
if (
|
|
23
|
+
if (field.schema?.numeric_precision === 20) {
|
|
26
24
|
return 'bigInteger';
|
|
27
25
|
}
|
|
28
|
-
else if (
|
|
26
|
+
else if (field.schema?.numeric_precision === 1) {
|
|
29
27
|
return 'boolean';
|
|
30
28
|
}
|
|
31
|
-
else if (
|
|
29
|
+
else if (field.schema?.numeric_precision || field.schema?.numeric_scale) {
|
|
32
30
|
return 'decimal';
|
|
33
31
|
}
|
|
34
32
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { KNEX_TYPES } from '@directus/shared/constants';
|
|
2
|
-
import { Field, Relation, Type } from '@directus/shared/types';
|
|
3
|
-
import { Knex } from 'knex';
|
|
4
|
-
import { DatabaseClient } from '../../../types';
|
|
1
|
+
import type { KNEX_TYPES } from '@directus/shared/constants';
|
|
2
|
+
import type { Field, Relation, Type } from '@directus/shared/types';
|
|
3
|
+
import type { Knex } from 'knex';
|
|
4
|
+
import type { DatabaseClient } from '../../../types';
|
|
5
5
|
import { DatabaseHelper } from '../types';
|
|
6
6
|
export type Options = {
|
|
7
7
|
nullable?: boolean;
|
package/dist/database/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import SchemaInspector from '@directus/schema';
|
|
2
2
|
import { Knex } from 'knex';
|
|
3
|
-
import { DatabaseClient } from '../types';
|
|
3
|
+
import type { DatabaseClient } from '../types';
|
|
4
4
|
export default function getDatabase(): Knex;
|
|
5
5
|
export declare function getSchemaInspector(): ReturnType<typeof SchemaInspector>;
|
|
6
6
|
/**
|
package/dist/database/index.js
CHANGED
|
@@ -5,16 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.validateDatabaseExtensions = exports.validateMigrations = exports.isInstalled = exports.getDatabaseClient = exports.validateDatabaseConnection = exports.hasDatabaseConnection = exports.getDatabaseVersion = exports.getSchemaInspector = void 0;
|
|
7
7
|
const schema_1 = __importDefault(require("@directus/schema"));
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
9
|
const knex_1 = require("knex");
|
|
10
|
+
const lodash_1 = require("lodash");
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
9
12
|
const perf_hooks_1 = require("perf_hooks");
|
|
13
|
+
const util_1 = require("util");
|
|
10
14
|
const env_1 = __importDefault(require("../env"));
|
|
11
15
|
const logger_1 = __importDefault(require("../logger"));
|
|
12
16
|
const get_config_from_env_1 = require("../utils/get-config-from-env");
|
|
13
17
|
const validate_env_1 = require("../utils/validate-env");
|
|
14
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
15
|
-
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const lodash_1 = require("lodash");
|
|
17
|
-
const util_1 = require("util");
|
|
18
18
|
const helpers_1 = require("./helpers");
|
|
19
19
|
let database = null;
|
|
20
20
|
let inspector = null;
|
|
@@ -30,7 +30,7 @@ function getDatabase() {
|
|
|
30
30
|
requiredEnvVars.push('DB_FILENAME');
|
|
31
31
|
break;
|
|
32
32
|
case 'oracledb':
|
|
33
|
-
if (!env_1.default
|
|
33
|
+
if (!env_1.default['DB_CONNECT_STRING']) {
|
|
34
34
|
requiredEnvVars.push('DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USER', 'DB_PASSWORD');
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
@@ -47,7 +47,7 @@ function getDatabase() {
|
|
|
47
47
|
}
|
|
48
48
|
break;
|
|
49
49
|
case 'mssql':
|
|
50
|
-
if (!env_1.default
|
|
50
|
+
if (!env_1.default['DB_TYPE'] || env_1.default['DB_TYPE'] === 'default') {
|
|
51
51
|
requiredEnvVars.push('DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USER', 'DB_PASSWORD');
|
|
52
52
|
}
|
|
53
53
|
break;
|
|
@@ -145,7 +145,7 @@ function getDatabaseVersion() {
|
|
|
145
145
|
}
|
|
146
146
|
exports.getDatabaseVersion = getDatabaseVersion;
|
|
147
147
|
async function hasDatabaseConnection(database) {
|
|
148
|
-
database = database
|
|
148
|
+
database = database ?? getDatabase();
|
|
149
149
|
try {
|
|
150
150
|
if (getDatabaseClient(database) === 'oracle') {
|
|
151
151
|
await database.raw('select 1 from DUAL');
|
|
@@ -161,7 +161,7 @@ async function hasDatabaseConnection(database) {
|
|
|
161
161
|
}
|
|
162
162
|
exports.hasDatabaseConnection = hasDatabaseConnection;
|
|
163
163
|
async function validateDatabaseConnection(database) {
|
|
164
|
-
database = database
|
|
164
|
+
database = database ?? getDatabase();
|
|
165
165
|
try {
|
|
166
166
|
if (getDatabaseClient(database) === 'oracle') {
|
|
167
167
|
await database.raw('select 1 from DUAL');
|
|
@@ -178,7 +178,7 @@ async function validateDatabaseConnection(database) {
|
|
|
178
178
|
}
|
|
179
179
|
exports.validateDatabaseConnection = validateDatabaseConnection;
|
|
180
180
|
function getDatabaseClient(database) {
|
|
181
|
-
database = database
|
|
181
|
+
database = database ?? getDatabase();
|
|
182
182
|
switch (database.client.constructor.name) {
|
|
183
183
|
case 'Client_MySQL':
|
|
184
184
|
return 'mysql';
|
|
@@ -211,7 +211,7 @@ async function validateMigrations() {
|
|
|
211
211
|
const database = getDatabase();
|
|
212
212
|
try {
|
|
213
213
|
let migrationFiles = await fs_extra_1.default.readdir(path_1.default.join(__dirname, 'migrations'));
|
|
214
|
-
const customMigrationsPath = path_1.default.resolve(env_1.default
|
|
214
|
+
const customMigrationsPath = path_1.default.resolve(env_1.default['EXTENSIONS_PATH'], 'migrations');
|
|
215
215
|
let customMigrationFiles = ((await fs_extra_1.default.pathExists(customMigrationsPath)) && (await fs_extra_1.default.readdir(customMigrationsPath))) || [];
|
|
216
216
|
migrationFiles = migrationFiles.filter((file) => file.startsWith('run') === false && file.endsWith('.d.ts') === false);
|
|
217
217
|
customMigrationFiles = customMigrationFiles.filter((file) => file.endsWith('.js'));
|
|
@@ -250,15 +250,15 @@ async function validateDatabaseExtensions() {
|
|
|
250
250
|
}
|
|
251
251
|
exports.validateDatabaseExtensions = validateDatabaseExtensions;
|
|
252
252
|
async function validateDatabaseCharset(database) {
|
|
253
|
-
database = database
|
|
253
|
+
database = database ?? getDatabase();
|
|
254
254
|
if (getDatabaseClient(database) === 'mysql') {
|
|
255
255
|
const { collation } = await database.select(database.raw(`@@collation_database as collation`)).first();
|
|
256
256
|
const tables = await database('information_schema.tables')
|
|
257
257
|
.select({ name: 'TABLE_NAME', collation: 'TABLE_COLLATION' })
|
|
258
|
-
.where({ TABLE_SCHEMA: env_1.default
|
|
258
|
+
.where({ TABLE_SCHEMA: env_1.default['DB_DATABASE'] });
|
|
259
259
|
const columns = await database('information_schema.columns')
|
|
260
260
|
.select({ table_name: 'TABLE_NAME', name: 'COLUMN_NAME', collation: 'COLLATION_NAME' })
|
|
261
|
-
.where({ TABLE_SCHEMA: env_1.default
|
|
261
|
+
.where({ TABLE_SCHEMA: env_1.default['DB_DATABASE'] })
|
|
262
262
|
.whereNot({ COLLATION_NAME: collation });
|
|
263
263
|
let inconsistencies = '';
|
|
264
264
|
for (const table of tables) {
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.down = exports.up = void 0;
|
|
4
4
|
const utils_1 = require("@directus/shared/utils");
|
|
5
5
|
async function up(knex) {
|
|
6
|
-
var _a;
|
|
7
6
|
await knex.schema.alterTable('directus_relations', (table) => {
|
|
8
7
|
table.string('sort_field');
|
|
9
8
|
});
|
|
@@ -12,7 +11,7 @@ async function up(knex) {
|
|
|
12
11
|
.from('directus_fields')
|
|
13
12
|
.whereIn('interface', ['one-to-many', 'm2a-builder', 'many-to-many']);
|
|
14
13
|
for (const field of fieldsWithSort) {
|
|
15
|
-
const options = typeof field.options === 'string' ? (0, utils_1.parseJSON)(field.options) :
|
|
14
|
+
const options = typeof field.options === 'string' ? (0, utils_1.parseJSON)(field.options) : field.options ?? {};
|
|
16
15
|
if ('sortField' in options) {
|
|
17
16
|
await knex('directus_relations')
|
|
18
17
|
.update({
|
|
@@ -14,7 +14,7 @@ async function up(knex) {
|
|
|
14
14
|
.select('id', 'many_collection', 'many_field', 'one_collection')
|
|
15
15
|
.from('directus_relations');
|
|
16
16
|
const constraintsToAdd = relations.filter((relation) => {
|
|
17
|
-
const exists = !!foreignKeys.find((fk) => fk.table ===
|
|
17
|
+
const exists = !!foreignKeys.find((fk) => fk.table === relation?.many_collection && fk.column === relation?.many_field);
|
|
18
18
|
return exists === false;
|
|
19
19
|
});
|
|
20
20
|
const corruptedRelations = [];
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.down = exports.up = void 0;
|
|
7
|
-
const logger_1 = __importDefault(require("../../logger"));
|
|
8
7
|
const knex_schema_inspector_1 = __importDefault(require("knex-schema-inspector"));
|
|
8
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
9
9
|
/**
|
|
10
10
|
* Things to keep in mind:
|
|
11
11
|
*
|
|
@@ -93,7 +93,7 @@ async function up(knex) {
|
|
|
93
93
|
fk.foreign_key_column === constraint.references.split('.')[1]);
|
|
94
94
|
try {
|
|
95
95
|
await knex.schema.alterTable(update.table, (table) => {
|
|
96
|
-
table.dropForeign([constraint.column],
|
|
96
|
+
table.dropForeign([constraint.column], existingForeignKey?.constraint_name || undefined);
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
catch (err) {
|