@supabase/pg-delta 1.0.0-alpha.3 → 1.0.0-alpha.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/README.md +22 -0
- package/dist/cli/bin/cli.js +0 -0
- package/dist/cli/commands/plan.js +21 -0
- package/dist/cli/utils.d.ts +2 -0
- package/dist/cli/utils.js +1 -1
- package/dist/core/objects/table/table.model.d.ts +4 -2
- package/dist/core/objects/table/table.model.js +3 -0
- package/dist/core/objects/trigger/changes/trigger.alter.js +23 -0
- package/dist/core/objects/trigger/changes/trigger.create.js +2 -1
- package/dist/core/objects/trigger/trigger.model.d.ts +1 -0
- package/dist/core/objects/trigger/trigger.model.js +3 -0
- package/dist/core/plan/apply.js +3 -3
- package/dist/core/plan/create.js +34 -15
- package/dist/core/plan/sql-format/constants.d.ts +2 -0
- package/dist/core/plan/sql-format/constants.js +11 -0
- package/dist/core/plan/sql-format/fixtures.d.ts +2 -0
- package/dist/core/plan/sql-format/fixtures.js +2449 -0
- package/dist/core/plan/sql-format/format-utils.d.ts +37 -0
- package/dist/core/plan/sql-format/format-utils.js +274 -0
- package/dist/core/plan/sql-format/formatters.d.ts +20 -0
- package/dist/core/plan/sql-format/formatters.js +737 -0
- package/dist/core/plan/sql-format/index.d.ts +2 -0
- package/dist/core/plan/sql-format/index.js +98 -0
- package/dist/core/plan/sql-format/keyword-case.d.ts +2 -0
- package/dist/core/plan/sql-format/keyword-case.js +868 -0
- package/dist/core/plan/sql-format/protect.d.ts +3 -0
- package/dist/core/plan/sql-format/protect.js +269 -0
- package/dist/core/plan/sql-format/sql-scanner.d.ts +59 -0
- package/dist/core/plan/sql-format/sql-scanner.js +202 -0
- package/dist/core/plan/sql-format/tokenizer.d.ts +22 -0
- package/dist/core/plan/sql-format/tokenizer.js +118 -0
- package/dist/core/plan/sql-format/types.d.ts +28 -0
- package/dist/core/plan/sql-format/types.js +1 -0
- package/dist/core/plan/sql-format/wrap.d.ts +2 -0
- package/dist/core/plan/sql-format/wrap.js +165 -0
- package/dist/core/plan/sql-format.d.ts +2 -0
- package/dist/core/plan/sql-format.js +1 -0
- package/dist/core/plan/statements.d.ts +2 -1
- package/dist/core/plan/statements.js +6 -2
- package/dist/core/postgres-config.d.ts +15 -0
- package/dist/core/postgres-config.js +30 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +37 -22
- package/src/cli/app.ts +28 -0
- package/src/cli/bin/cli.ts +9 -0
- package/src/cli/commands/apply.ts +101 -0
- package/src/cli/commands/plan.ts +195 -0
- package/src/cli/commands/sync.ts +185 -0
- package/src/cli/formatters/index.ts +5 -0
- package/src/cli/formatters/tree/tree-builder.ts +380 -0
- package/src/cli/formatters/tree/tree-renderer.ts +372 -0
- package/src/cli/formatters/tree/tree.ts +237 -0
- package/src/cli/utils/integrations.ts +42 -0
- package/src/cli/utils.ts +231 -0
- package/src/core/catalog.diff.ts +246 -0
- package/src/core/catalog.model.ts +384 -0
- package/src/core/change.types.ts +44 -0
- package/src/core/context.ts +26 -0
- package/src/core/depend.ts +1870 -0
- package/src/core/expand-replace-dependencies.ts +380 -0
- package/src/core/fingerprint.ts +204 -0
- package/src/core/integrations/filter/dsl.ts +204 -0
- package/src/core/integrations/filter/extractors.ts +145 -0
- package/src/core/integrations/filter/filter.types.ts +3 -0
- package/src/core/integrations/integration-dsl.ts +24 -0
- package/src/core/integrations/integration.types.ts +7 -0
- package/src/core/integrations/serialize/dsl.ts +77 -0
- package/src/core/integrations/serialize/serialize.types.ts +3 -0
- package/src/core/integrations/supabase.ts +121 -0
- package/src/core/objects/aggregate/aggregate.diff.test.ts +215 -0
- package/src/core/objects/aggregate/aggregate.diff.ts +278 -0
- package/src/core/objects/aggregate/aggregate.model.ts +317 -0
- package/src/core/objects/aggregate/changes/aggregate.alter.test.ts +64 -0
- package/src/core/objects/aggregate/changes/aggregate.alter.ts +32 -0
- package/src/core/objects/aggregate/changes/aggregate.base.ts +20 -0
- package/src/core/objects/aggregate/changes/aggregate.comment.test.ts +86 -0
- package/src/core/objects/aggregate/changes/aggregate.comment.ts +62 -0
- package/src/core/objects/aggregate/changes/aggregate.create.test.ts +101 -0
- package/src/core/objects/aggregate/changes/aggregate.create.ts +329 -0
- package/src/core/objects/aggregate/changes/aggregate.drop.test.ts +78 -0
- package/src/core/objects/aggregate/changes/aggregate.drop.ts +32 -0
- package/src/core/objects/aggregate/changes/aggregate.privilege.test.ts +130 -0
- package/src/core/objects/aggregate/changes/aggregate.privilege.ts +146 -0
- package/src/core/objects/aggregate/changes/aggregate.types.ts +12 -0
- package/src/core/objects/base.change.ts +62 -0
- package/src/core/objects/base.default-privileges.ts +204 -0
- package/src/core/objects/base.diff.ts +20 -0
- package/src/core/objects/base.model.ts +82 -0
- package/src/core/objects/base.privilege-diff.ts +299 -0
- package/src/core/objects/base.privilege.ts +184 -0
- package/src/core/objects/collation/changes/collation.alter.test.ts +63 -0
- package/src/core/objects/collation/changes/collation.alter.ts +79 -0
- package/src/core/objects/collation/changes/collation.base.ts +20 -0
- package/src/core/objects/collation/changes/collation.comment.ts +68 -0
- package/src/core/objects/collation/changes/collation.create.test.ts +51 -0
- package/src/core/objects/collation/changes/collation.create.ts +106 -0
- package/src/core/objects/collation/changes/collation.drop.test.ts +28 -0
- package/src/core/objects/collation/changes/collation.drop.ts +37 -0
- package/src/core/objects/collation/changes/collation.types.ts +10 -0
- package/src/core/objects/collation/collation.diff.test.ts +100 -0
- package/src/core/objects/collation/collation.diff.ts +126 -0
- package/src/core/objects/collation/collation.model.ts +224 -0
- package/src/core/objects/domain/changes/domain.alter.test.ts +316 -0
- package/src/core/objects/domain/changes/domain.alter.ts +286 -0
- package/src/core/objects/domain/changes/domain.base.ts +20 -0
- package/src/core/objects/domain/changes/domain.comment.ts +59 -0
- package/src/core/objects/domain/changes/domain.create.test.ts +65 -0
- package/src/core/objects/domain/changes/domain.create.ts +118 -0
- package/src/core/objects/domain/changes/domain.drop.test.ts +30 -0
- package/src/core/objects/domain/changes/domain.drop.ts +34 -0
- package/src/core/objects/domain/changes/domain.privilege.ts +171 -0
- package/src/core/objects/domain/changes/domain.types.ts +12 -0
- package/src/core/objects/domain/domain.diff.test.ts +284 -0
- package/src/core/objects/domain/domain.diff.ts +358 -0
- package/src/core/objects/domain/domain.model.ts +190 -0
- package/src/core/objects/event-trigger/changes/event-trigger.alter.test.ts +50 -0
- package/src/core/objects/event-trigger/changes/event-trigger.alter.ts +82 -0
- package/src/core/objects/event-trigger/changes/event-trigger.base.ts +20 -0
- package/src/core/objects/event-trigger/changes/event-trigger.comment.ts +66 -0
- package/src/core/objects/event-trigger/changes/event-trigger.create.test.ts +24 -0
- package/src/core/objects/event-trigger/changes/event-trigger.create.ts +72 -0
- package/src/core/objects/event-trigger/changes/event-trigger.drop.test.ts +22 -0
- package/src/core/objects/event-trigger/changes/event-trigger.drop.ts +34 -0
- package/src/core/objects/event-trigger/changes/event-trigger.types.ts +10 -0
- package/src/core/objects/event-trigger/event-trigger.diff.test.ts +126 -0
- package/src/core/objects/event-trigger/event-trigger.diff.ts +126 -0
- package/src/core/objects/event-trigger/event-trigger.model.ts +106 -0
- package/src/core/objects/extension/changes/extension.alter.test.ts +58 -0
- package/src/core/objects/extension/changes/extension.alter.ts +78 -0
- package/src/core/objects/extension/changes/extension.base.ts +20 -0
- package/src/core/objects/extension/changes/extension.comment.ts +64 -0
- package/src/core/objects/extension/changes/extension.create.test.ts +25 -0
- package/src/core/objects/extension/changes/extension.create.ts +63 -0
- package/src/core/objects/extension/changes/extension.drop.test.ts +23 -0
- package/src/core/objects/extension/changes/extension.drop.ts +34 -0
- package/src/core/objects/extension/changes/extension.types.ts +10 -0
- package/src/core/objects/extension/extension.diff.test.ts +42 -0
- package/src/core/objects/extension/extension.diff.ts +90 -0
- package/src/core/objects/extension/extension.model.ts +280 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.alter.test.ts +125 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.alter.ts +101 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.base.ts +20 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.comment.ts +72 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.create.test.ts +125 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.create.ts +95 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.drop.test.ts +23 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.drop.ts +36 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.privilege.ts +172 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/changes/foreign-data-wrapper.types.ts +12 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/foreign-data-wrapper.diff.test.ts +179 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/foreign-data-wrapper.diff.ts +341 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper/foreign-data-wrapper.model.ts +149 -0
- package/src/core/objects/foreign-data-wrapper/foreign-data-wrapper.types.ts +10 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.alter.test.ts +309 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.alter.ts +341 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.base.ts +20 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.comment.ts +72 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.create.test.ts +201 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.create.ts +81 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.drop.test.ts +43 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.drop.ts +37 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.privilege.ts +181 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.types.ts +12 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/foreign-table.diff.test.ts +813 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/foreign-table.diff.ts +406 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/foreign-table.model.ts +242 -0
- package/src/core/objects/foreign-data-wrapper/server/changes/server.alter.test.ts +168 -0
- package/src/core/objects/foreign-data-wrapper/server/changes/server.alter.ts +126 -0
- package/src/core/objects/foreign-data-wrapper/server/changes/server.base.ts +20 -0
- package/src/core/objects/foreign-data-wrapper/server/changes/server.comment.ts +60 -0
- package/src/core/objects/foreign-data-wrapper/server/changes/server.create.test.ts +131 -0
- package/src/core/objects/foreign-data-wrapper/server/changes/server.create.ts +81 -0
- package/src/core/objects/foreign-data-wrapper/server/changes/server.drop.test.ts +24 -0
- package/src/core/objects/foreign-data-wrapper/server/changes/server.drop.ts +34 -0
- package/src/core/objects/foreign-data-wrapper/server/changes/server.privilege.ts +164 -0
- package/src/core/objects/foreign-data-wrapper/server/changes/server.types.ts +12 -0
- package/src/core/objects/foreign-data-wrapper/server/server.diff.test.ts +167 -0
- package/src/core/objects/foreign-data-wrapper/server/server.diff.ts +317 -0
- package/src/core/objects/foreign-data-wrapper/server/server.model.ts +133 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.alter.test.ts +82 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.alter.ts +69 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.base.ts +20 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.create.test.ts +85 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.create.ts +66 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.drop.test.ts +53 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.drop.ts +40 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/changes/user-mapping.types.ts +8 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/user-mapping.diff.test.ts +77 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/user-mapping.diff.ts +107 -0
- package/src/core/objects/foreign-data-wrapper/user-mapping/user-mapping.model.ts +96 -0
- package/src/core/objects/index/changes/index.alter.test.ts +200 -0
- package/src/core/objects/index/changes/index.alter.ts +144 -0
- package/src/core/objects/index/changes/index.base.ts +20 -0
- package/src/core/objects/index/changes/index.comment.ts +63 -0
- package/src/core/objects/index/changes/index.create.test.ts +66 -0
- package/src/core/objects/index/changes/index.create.ts +68 -0
- package/src/core/objects/index/changes/index.drop.test.ts +44 -0
- package/src/core/objects/index/changes/index.drop.ts +34 -0
- package/src/core/objects/index/changes/index.types.ts +6 -0
- package/src/core/objects/index/changes/utils.ts +16 -0
- package/src/core/objects/index/index.diff.test.ts +153 -0
- package/src/core/objects/index/index.diff.ts +243 -0
- package/src/core/objects/index/index.model.ts +370 -0
- package/src/core/objects/language/changes/language.alter.test.ts +33 -0
- package/src/core/objects/language/changes/language.alter.ts +53 -0
- package/src/core/objects/language/changes/language.base.ts +20 -0
- package/src/core/objects/language/changes/language.comment.ts +58 -0
- package/src/core/objects/language/changes/language.create.test.ts +27 -0
- package/src/core/objects/language/changes/language.create.ts +104 -0
- package/src/core/objects/language/changes/language.drop.test.ts +25 -0
- package/src/core/objects/language/changes/language.drop.ts +39 -0
- package/src/core/objects/language/changes/language.privilege.ts +172 -0
- package/src/core/objects/language/changes/language.types.ts +12 -0
- package/src/core/objects/language/language.diff.test.ts +53 -0
- package/src/core/objects/language/language.diff.ts +176 -0
- package/src/core/objects/language/language.model.ts +150 -0
- package/src/core/objects/materialized-view/changes/materialized-view.alter.test.ts +123 -0
- package/src/core/objects/materialized-view/changes/materialized-view.alter.ts +113 -0
- package/src/core/objects/materialized-view/changes/materialized-view.base.ts +20 -0
- package/src/core/objects/materialized-view/changes/materialized-view.comment.ts +176 -0
- package/src/core/objects/materialized-view/changes/materialized-view.create.test.ts +64 -0
- package/src/core/objects/materialized-view/changes/materialized-view.create.ts +93 -0
- package/src/core/objects/materialized-view/changes/materialized-view.drop.test.ts +34 -0
- package/src/core/objects/materialized-view/changes/materialized-view.drop.ts +60 -0
- package/src/core/objects/materialized-view/changes/materialized-view.privilege.ts +212 -0
- package/src/core/objects/materialized-view/changes/materialized-view.types.ts +12 -0
- package/src/core/objects/materialized-view/materialized-view.diff.test.ts +102 -0
- package/src/core/objects/materialized-view/materialized-view.diff.ts +451 -0
- package/src/core/objects/materialized-view/materialized-view.model.ts +258 -0
- package/src/core/objects/procedure/changes/procedure.alter.test.ts +1005 -0
- package/src/core/objects/procedure/changes/procedure.alter.ts +287 -0
- package/src/core/objects/procedure/changes/procedure.base.ts +20 -0
- package/src/core/objects/procedure/changes/procedure.comment.ts +70 -0
- package/src/core/objects/procedure/changes/procedure.create.test.ts +48 -0
- package/src/core/objects/procedure/changes/procedure.create.ts +92 -0
- package/src/core/objects/procedure/changes/procedure.drop.test.ts +85 -0
- package/src/core/objects/procedure/changes/procedure.drop.ts +49 -0
- package/src/core/objects/procedure/changes/procedure.privilege.ts +188 -0
- package/src/core/objects/procedure/changes/procedure.types.ts +12 -0
- package/src/core/objects/procedure/procedure.diff.test.ts +161 -0
- package/src/core/objects/procedure/procedure.diff.ts +404 -0
- package/src/core/objects/procedure/procedure.model.ts +264 -0
- package/src/core/objects/procedure/utils.ts +58 -0
- package/src/core/objects/publication/changes/publication.alter.test.ts +223 -0
- package/src/core/objects/publication/changes/publication.alter.ts +243 -0
- package/src/core/objects/publication/changes/publication.base.ts +20 -0
- package/src/core/objects/publication/changes/publication.comment.test.ts +70 -0
- package/src/core/objects/publication/changes/publication.comment.ts +64 -0
- package/src/core/objects/publication/changes/publication.create.test.ts +87 -0
- package/src/core/objects/publication/changes/publication.create.ts +82 -0
- package/src/core/objects/publication/changes/publication.drop.test.ts +46 -0
- package/src/core/objects/publication/changes/publication.drop.ts +29 -0
- package/src/core/objects/publication/changes/publication.types.ts +26 -0
- package/src/core/objects/publication/publication.diff.test.ts +292 -0
- package/src/core/objects/publication/publication.diff.ts +253 -0
- package/src/core/objects/publication/publication.model.ts +206 -0
- package/src/core/objects/publication/utils.ts +55 -0
- package/src/core/objects/rls-policy/changes/rls-policy.alter.test.ts +250 -0
- package/src/core/objects/rls-policy/changes/rls-policy.alter.ts +128 -0
- package/src/core/objects/rls-policy/changes/rls-policy.base.ts +20 -0
- package/src/core/objects/rls-policy/changes/rls-policy.comment.ts +69 -0
- package/src/core/objects/rls-policy/changes/rls-policy.create.test.ts +74 -0
- package/src/core/objects/rls-policy/changes/rls-policy.create.ts +100 -0
- package/src/core/objects/rls-policy/changes/rls-policy.drop.test.ts +28 -0
- package/src/core/objects/rls-policy/changes/rls-policy.drop.ts +39 -0
- package/src/core/objects/rls-policy/changes/rls-policy.types.ts +10 -0
- package/src/core/objects/rls-policy/rls-policy.diff.test.ts +79 -0
- package/src/core/objects/rls-policy/rls-policy.diff.ts +121 -0
- package/src/core/objects/rls-policy/rls-policy.model.ts +140 -0
- package/src/core/objects/role/changes/role.alter.test.ts +346 -0
- package/src/core/objects/role/changes/role.alter.ts +110 -0
- package/src/core/objects/role/changes/role.base.ts +24 -0
- package/src/core/objects/role/changes/role.comment.ts +55 -0
- package/src/core/objects/role/changes/role.create.test.ts +52 -0
- package/src/core/objects/role/changes/role.create.ts +102 -0
- package/src/core/objects/role/changes/role.drop.test.ts +29 -0
- package/src/core/objects/role/changes/role.drop.ts +34 -0
- package/src/core/objects/role/changes/role.privilege.ts +376 -0
- package/src/core/objects/role/changes/role.types.ts +12 -0
- package/src/core/objects/role/role.diff.test.ts +44 -0
- package/src/core/objects/role/role.diff.ts +479 -0
- package/src/core/objects/role/role.model.ts +344 -0
- package/src/core/objects/rule/changes/rule.alter.test.ts +78 -0
- package/src/core/objects/rule/changes/rule.alter.ts +72 -0
- package/src/core/objects/rule/changes/rule.base.ts +20 -0
- package/src/core/objects/rule/changes/rule.comment.test.ts +55 -0
- package/src/core/objects/rule/changes/rule.comment.ts +62 -0
- package/src/core/objects/rule/changes/rule.create.test.ts +59 -0
- package/src/core/objects/rule/changes/rule.create.ts +42 -0
- package/src/core/objects/rule/changes/rule.drop.test.ts +38 -0
- package/src/core/objects/rule/changes/rule.drop.ts +29 -0
- package/src/core/objects/rule/changes/rule.types.ts +12 -0
- package/src/core/objects/rule/rule.diff.test.ts +132 -0
- package/src/core/objects/rule/rule.diff.ts +79 -0
- package/src/core/objects/rule/rule.model.ts +173 -0
- package/src/core/objects/schema/changes/schema.alter.test.ts +28 -0
- package/src/core/objects/schema/changes/schema.alter.ts +45 -0
- package/src/core/objects/schema/changes/schema.base.ts +20 -0
- package/src/core/objects/schema/changes/schema.comment.ts +56 -0
- package/src/core/objects/schema/changes/schema.create.test.ts +22 -0
- package/src/core/objects/schema/changes/schema.create.ts +47 -0
- package/src/core/objects/schema/changes/schema.drop.test.ts +20 -0
- package/src/core/objects/schema/changes/schema.drop.ts +34 -0
- package/src/core/objects/schema/changes/schema.privilege.ts +175 -0
- package/src/core/objects/schema/changes/schema.types.ts +12 -0
- package/src/core/objects/schema/schema.diff.test.ts +42 -0
- package/src/core/objects/schema/schema.diff.ts +209 -0
- package/src/core/objects/schema/schema.model.ts +107 -0
- package/src/core/objects/sequence/changes/sequence.alter.test.ts +151 -0
- package/src/core/objects/sequence/changes/sequence.alter.ts +115 -0
- package/src/core/objects/sequence/changes/sequence.base.ts +20 -0
- package/src/core/objects/sequence/changes/sequence.comment.ts +60 -0
- package/src/core/objects/sequence/changes/sequence.create.test.ts +84 -0
- package/src/core/objects/sequence/changes/sequence.create.ts +111 -0
- package/src/core/objects/sequence/changes/sequence.drop.test.ts +32 -0
- package/src/core/objects/sequence/changes/sequence.drop.ts +37 -0
- package/src/core/objects/sequence/changes/sequence.privilege.ts +179 -0
- package/src/core/objects/sequence/changes/sequence.types.ts +12 -0
- package/src/core/objects/sequence/sequence.diff.test.ts +141 -0
- package/src/core/objects/sequence/sequence.diff.ts +359 -0
- package/src/core/objects/sequence/sequence.model.ts +185 -0
- package/src/core/objects/subscription/changes/subscription.alter.test.ts +124 -0
- package/src/core/objects/subscription/changes/subscription.alter.ts +110 -0
- package/src/core/objects/subscription/changes/subscription.base.ts +20 -0
- package/src/core/objects/subscription/changes/subscription.comment.test.ts +67 -0
- package/src/core/objects/subscription/changes/subscription.comment.ts +64 -0
- package/src/core/objects/subscription/changes/subscription.create.test.ts +77 -0
- package/src/core/objects/subscription/changes/subscription.create.ts +69 -0
- package/src/core/objects/subscription/changes/subscription.drop.test.ts +46 -0
- package/src/core/objects/subscription/changes/subscription.drop.ts +20 -0
- package/src/core/objects/subscription/changes/subscription.types.ts +22 -0
- package/src/core/objects/subscription/subscription.diff.test.ts +232 -0
- package/src/core/objects/subscription/subscription.diff.ts +241 -0
- package/src/core/objects/subscription/subscription.model.ts +190 -0
- package/src/core/objects/subscription/utils.ts +156 -0
- package/src/core/objects/table/changes/table.alter.test.ts +823 -0
- package/src/core/objects/table/changes/table.alter.ts +806 -0
- package/src/core/objects/table/changes/table.base.ts +20 -0
- package/src/core/objects/table/changes/table.comment.ts +266 -0
- package/src/core/objects/table/changes/table.create.test.ts +150 -0
- package/src/core/objects/table/changes/table.create.ts +188 -0
- package/src/core/objects/table/changes/table.drop.test.ts +34 -0
- package/src/core/objects/table/changes/table.drop.ts +45 -0
- package/src/core/objects/table/changes/table.privilege.ts +200 -0
- package/src/core/objects/table/changes/table.types.ts +12 -0
- package/src/core/objects/table/table.diff.test.ts +711 -0
- package/src/core/objects/table/table.diff.ts +953 -0
- package/src/core/objects/table/table.model.ts +460 -0
- package/src/core/objects/trigger/changes/trigger.alter.test.ts +46 -0
- package/src/core/objects/trigger/changes/trigger.alter.ts +76 -0
- package/src/core/objects/trigger/changes/trigger.base.ts +20 -0
- package/src/core/objects/trigger/changes/trigger.comment.ts +64 -0
- package/src/core/objects/trigger/changes/trigger.create.test.ts +43 -0
- package/src/core/objects/trigger/changes/trigger.create.ts +85 -0
- package/src/core/objects/trigger/changes/trigger.drop.test.ts +43 -0
- package/src/core/objects/trigger/changes/trigger.drop.ts +39 -0
- package/src/core/objects/trigger/changes/trigger.types.ts +10 -0
- package/src/core/objects/trigger/trigger.diff.test.ts +83 -0
- package/src/core/objects/trigger/trigger.diff.ts +116 -0
- package/src/core/objects/trigger/trigger.model.ts +252 -0
- package/src/core/objects/type/composite-type/changes/composite-type.alter.test.ts +202 -0
- package/src/core/objects/type/composite-type/changes/composite-type.alter.ts +174 -0
- package/src/core/objects/type/composite-type/changes/composite-type.base.ts +20 -0
- package/src/core/objects/type/composite-type/changes/composite-type.comment.ts +145 -0
- package/src/core/objects/type/composite-type/changes/composite-type.create.test.ts +101 -0
- package/src/core/objects/type/composite-type/changes/composite-type.create.ts +95 -0
- package/src/core/objects/type/composite-type/changes/composite-type.drop.test.ts +33 -0
- package/src/core/objects/type/composite-type/changes/composite-type.drop.ts +37 -0
- package/src/core/objects/type/composite-type/changes/composite-type.privilege.ts +175 -0
- package/src/core/objects/type/composite-type/changes/composite-type.types.ts +12 -0
- package/src/core/objects/type/composite-type/composite-type.diff.test.ts +191 -0
- package/src/core/objects/type/composite-type/composite-type.diff.ts +372 -0
- package/src/core/objects/type/composite-type/composite-type.model.ts +252 -0
- package/src/core/objects/type/enum/changes/enum.alter.test.ts +104 -0
- package/src/core/objects/type/enum/changes/enum.alter.ts +91 -0
- package/src/core/objects/type/enum/changes/enum.base.ts +20 -0
- package/src/core/objects/type/enum/changes/enum.comment.ts +64 -0
- package/src/core/objects/type/enum/changes/enum.create.test.ts +28 -0
- package/src/core/objects/type/enum/changes/enum.create.ts +56 -0
- package/src/core/objects/type/enum/changes/enum.drop.test.ts +25 -0
- package/src/core/objects/type/enum/changes/enum.drop.ts +34 -0
- package/src/core/objects/type/enum/changes/enum.privilege.ts +175 -0
- package/src/core/objects/type/enum/changes/enum.types.ts +12 -0
- package/src/core/objects/type/enum/enum.diff.test.ts +191 -0
- package/src/core/objects/type/enum/enum.diff.ts +396 -0
- package/src/core/objects/type/enum/enum.model.ts +194 -0
- package/src/core/objects/type/range/changes/range.alter.test.ts +27 -0
- package/src/core/objects/type/range/changes/range.alter.ts +51 -0
- package/src/core/objects/type/range/changes/range.base.ts +20 -0
- package/src/core/objects/type/range/changes/range.comment.ts +64 -0
- package/src/core/objects/type/range/changes/range.create.test.ts +51 -0
- package/src/core/objects/type/range/changes/range.create.ts +151 -0
- package/src/core/objects/type/range/changes/range.drop.test.ts +26 -0
- package/src/core/objects/type/range/changes/range.drop.ts +34 -0
- package/src/core/objects/type/range/changes/range.privilege.ts +175 -0
- package/src/core/objects/type/range/changes/range.types.ts +12 -0
- package/src/core/objects/type/range/range.diff.test.ts +70 -0
- package/src/core/objects/type/range/range.diff.ts +259 -0
- package/src/core/objects/type/range/range.model.ts +187 -0
- package/src/core/objects/type/type.types.ts +5 -0
- package/src/core/objects/utils.ts +171 -0
- package/src/core/objects/view/changes/view.alter.test.ts +110 -0
- package/src/core/objects/view/changes/view.alter.ts +112 -0
- package/src/core/objects/view/changes/view.base.ts +20 -0
- package/src/core/objects/view/changes/view.comment.ts +59 -0
- package/src/core/objects/view/changes/view.create.test.ts +65 -0
- package/src/core/objects/view/changes/view.create.ts +73 -0
- package/src/core/objects/view/changes/view.drop.test.ts +34 -0
- package/src/core/objects/view/changes/view.drop.ts +40 -0
- package/src/core/objects/view/changes/view.privilege.ts +200 -0
- package/src/core/objects/view/changes/view.types.ts +12 -0
- package/src/core/objects/view/view.diff.test.ts +91 -0
- package/src/core/objects/view/view.diff.ts +365 -0
- package/src/core/objects/view/view.model.ts +276 -0
- package/src/core/plan/apply.ts +190 -0
- package/src/core/plan/create.ts +432 -0
- package/src/core/plan/hierarchy.ts +574 -0
- package/src/core/plan/index.ts +29 -0
- package/src/core/plan/io.ts +20 -0
- package/src/core/plan/risk.ts +48 -0
- package/src/core/plan/serialize.ts +195 -0
- package/src/core/plan/sql-format/constants.ts +13 -0
- package/src/core/plan/sql-format/fixtures.ts +2806 -0
- package/src/core/plan/sql-format/format-comment-literals.test.ts +96 -0
- package/src/core/plan/sql-format/format-functions.test.ts +127 -0
- package/src/core/plan/sql-format/format-lowercase-coverage.test.ts +67 -0
- package/src/core/plan/sql-format/format-off.test.ts +809 -0
- package/src/core/plan/sql-format/format-pretty-lower-leading.test.ts +1056 -0
- package/src/core/plan/sql-format/format-pretty-narrow.test.ts +1283 -0
- package/src/core/plan/sql-format/format-pretty-preserve.test.ts +1052 -0
- package/src/core/plan/sql-format/format-pretty-upper.test.ts +1045 -0
- package/src/core/plan/sql-format/format-stress.test.ts +616 -0
- package/src/core/plan/sql-format/format-utils.test.ts +91 -0
- package/src/core/plan/sql-format/format-utils.ts +391 -0
- package/src/core/plan/sql-format/formatters.ts +921 -0
- package/src/core/plan/sql-format/index.ts +149 -0
- package/src/core/plan/sql-format/keyword-case.test.ts +118 -0
- package/src/core/plan/sql-format/keyword-case.ts +1085 -0
- package/src/core/plan/sql-format/protect.test.ts +127 -0
- package/src/core/plan/sql-format/protect.ts +337 -0
- package/src/core/plan/sql-format/sql-scanner.test.ts +240 -0
- package/src/core/plan/sql-format/sql-scanner.ts +252 -0
- package/src/core/plan/sql-format/tokenizer.test.ts +68 -0
- package/src/core/plan/sql-format/tokenizer.ts +152 -0
- package/src/core/plan/sql-format/types.ts +31 -0
- package/src/core/plan/sql-format/wrap.test.ts +119 -0
- package/src/core/plan/sql-format/wrap.ts +196 -0
- package/src/core/plan/sql-format.ts +2 -0
- package/src/core/plan/statements.ts +22 -0
- package/src/core/plan/types.ts +165 -0
- package/src/core/postgres-config.ts +169 -0
- package/src/core/sort/custom-constraints.ts +161 -0
- package/src/core/sort/debug-visualization.ts +239 -0
- package/src/core/sort/dependency-filter.ts +224 -0
- package/src/core/sort/graph-builder.ts +223 -0
- package/src/core/sort/graph-utils.ts +51 -0
- package/src/core/sort/logical-sort.ts +590 -0
- package/src/core/sort/sort-changes.ts +234 -0
- package/src/core/sort/topological-sort.ts +184 -0
- package/src/core/sort/types.ts +112 -0
- package/src/core/sort/utils.ts +69 -0
- package/src/index.ts +14 -0
|
@@ -0,0 +1,1283 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { renderScript } from "./fixtures.ts";
|
|
3
|
+
|
|
4
|
+
describe("sql formatting snapshots", () => {
|
|
5
|
+
test("format-pretty-narrow", () => {
|
|
6
|
+
const output = [
|
|
7
|
+
"-- format: { maxWidth: 40 }",
|
|
8
|
+
renderScript({ maxWidth: 40 }),
|
|
9
|
+
]
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.join("\n");
|
|
12
|
+
expect(output).toMatchInlineSnapshot(`
|
|
13
|
+
"-- format: { maxWidth: 40 }
|
|
14
|
+
-- schema.create
|
|
15
|
+
CREATE SCHEMA
|
|
16
|
+
application_schema_with_very_long_name_for_wrapping_tests AUTHORIZATION admin;
|
|
17
|
+
|
|
18
|
+
-- schema.drop
|
|
19
|
+
DROP SCHEMA
|
|
20
|
+
application_schema_with_very_long_name_for_wrapping_tests;
|
|
21
|
+
|
|
22
|
+
-- schema.alter.change_owner
|
|
23
|
+
ALTER SCHEMA
|
|
24
|
+
application_schema_with_very_long_name_for_wrapping_tests OWNER TO new_admin;
|
|
25
|
+
|
|
26
|
+
-- schema.comment
|
|
27
|
+
COMMENT ON SCHEMA
|
|
28
|
+
application_schema_with_very_long_name_for_wrapping_tests IS 'application schema';
|
|
29
|
+
|
|
30
|
+
-- schema.drop_comment
|
|
31
|
+
COMMENT ON SCHEMA
|
|
32
|
+
application_schema_with_very_long_name_for_wrapping_tests IS NULL;
|
|
33
|
+
|
|
34
|
+
-- schema.grant
|
|
35
|
+
GRANT ALL ON SCHEMA
|
|
36
|
+
application_schema_with_very_long_name_for_wrapping_tests TO app_user WITH GRANT OPTION;
|
|
37
|
+
|
|
38
|
+
-- schema.revoke
|
|
39
|
+
REVOKE CREATE ON SCHEMA
|
|
40
|
+
application_schema_with_very_long_name_for_wrapping_tests FROM app_user;
|
|
41
|
+
|
|
42
|
+
-- schema.revoke_grant_option
|
|
43
|
+
REVOKE GRANT OPTION FOR USAGE
|
|
44
|
+
ON SCHEMA
|
|
45
|
+
application_schema_with_very_long_name_for_wrapping_tests FROM app_user;
|
|
46
|
+
|
|
47
|
+
-- extension.create
|
|
48
|
+
CREATE EXTENSION pgcrypto
|
|
49
|
+
WITH SCHEMA extensions;
|
|
50
|
+
|
|
51
|
+
-- extension.drop
|
|
52
|
+
DROP EXTENSION pgcrypto;
|
|
53
|
+
|
|
54
|
+
-- extension.alter.update_version
|
|
55
|
+
ALTER EXTENSION pgcrypto UPDATE TO '1.4';
|
|
56
|
+
|
|
57
|
+
-- extension.alter.set_schema
|
|
58
|
+
ALTER EXTENSION pgcrypto
|
|
59
|
+
SET SCHEMA public;
|
|
60
|
+
|
|
61
|
+
-- extension.comment
|
|
62
|
+
COMMENT ON EXTENSION pgcrypto IS
|
|
63
|
+
'cryptographic functions';
|
|
64
|
+
|
|
65
|
+
-- extension.drop_comment
|
|
66
|
+
COMMENT ON EXTENSION pgcrypto IS NULL;
|
|
67
|
+
|
|
68
|
+
-- domain.create
|
|
69
|
+
CREATE DOMAIN public.test_domain_all AS
|
|
70
|
+
custom.text[][]
|
|
71
|
+
COLLATE mycoll
|
|
72
|
+
DEFAULT 'hello'
|
|
73
|
+
NOT NULL
|
|
74
|
+
CHECK (VALUE <> '');
|
|
75
|
+
|
|
76
|
+
-- domain.drop
|
|
77
|
+
DROP DOMAIN public.test_domain_all;
|
|
78
|
+
|
|
79
|
+
-- domain.alter.set_default
|
|
80
|
+
ALTER DOMAIN public.test_domain_all
|
|
81
|
+
SET DEFAULT 'world';
|
|
82
|
+
|
|
83
|
+
-- domain.alter.drop_default
|
|
84
|
+
ALTER DOMAIN public.test_domain_all
|
|
85
|
+
DROP DEFAULT;
|
|
86
|
+
|
|
87
|
+
-- domain.alter.set_not_null
|
|
88
|
+
ALTER DOMAIN public.test_domain_all
|
|
89
|
+
SET NOT NULL;
|
|
90
|
+
|
|
91
|
+
-- domain.alter.drop_not_null
|
|
92
|
+
ALTER DOMAIN public.test_domain_all
|
|
93
|
+
DROP NOT NULL;
|
|
94
|
+
|
|
95
|
+
-- domain.alter.change_owner
|
|
96
|
+
ALTER DOMAIN public.test_domain_all
|
|
97
|
+
OWNER TO new_owner;
|
|
98
|
+
|
|
99
|
+
-- domain.alter.add_constraint
|
|
100
|
+
ALTER DOMAIN public.test_domain_all
|
|
101
|
+
ADD CONSTRAINT domain_len_chk
|
|
102
|
+
CHECK (char_length(VALUE) <= 255)
|
|
103
|
+
NOT VALID;
|
|
104
|
+
|
|
105
|
+
-- domain.alter.drop_constraint
|
|
106
|
+
ALTER DOMAIN public.test_domain_all
|
|
107
|
+
DROP CONSTRAINT domain_chk;
|
|
108
|
+
|
|
109
|
+
-- domain.alter.validate_constraint
|
|
110
|
+
ALTER DOMAIN public.test_domain_all
|
|
111
|
+
VALIDATE CONSTRAINT domain_len_chk;
|
|
112
|
+
|
|
113
|
+
-- domain.comment
|
|
114
|
+
COMMENT ON DOMAIN public.test_domain_all
|
|
115
|
+
IS 'domain comment';
|
|
116
|
+
|
|
117
|
+
-- domain.drop_comment
|
|
118
|
+
COMMENT ON DOMAIN public.test_domain_all
|
|
119
|
+
IS NULL;
|
|
120
|
+
|
|
121
|
+
-- domain.grant
|
|
122
|
+
GRANT ALL ON DOMAIN
|
|
123
|
+
public.test_domain_all TO app_user;
|
|
124
|
+
|
|
125
|
+
-- domain.revoke
|
|
126
|
+
REVOKE ALL ON DOMAIN
|
|
127
|
+
public.test_domain_all FROM app_user;
|
|
128
|
+
|
|
129
|
+
-- domain.revoke_grant_option
|
|
130
|
+
REVOKE GRANT OPTION FOR ALL ON DOMAIN
|
|
131
|
+
public.test_domain_all FROM app_user;
|
|
132
|
+
|
|
133
|
+
-- type.enum.create
|
|
134
|
+
CREATE TYPE public.test_enum AS ENUM (
|
|
135
|
+
'value1',
|
|
136
|
+
'value2',
|
|
137
|
+
'value3'
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
-- type.enum.drop
|
|
141
|
+
DROP TYPE public.test_enum;
|
|
142
|
+
|
|
143
|
+
-- type.enum.alter.change_owner
|
|
144
|
+
ALTER TYPE public.test_enum OWNER TO
|
|
145
|
+
new_owner;
|
|
146
|
+
|
|
147
|
+
-- type.enum.alter.add_value
|
|
148
|
+
ALTER TYPE public.test_enum
|
|
149
|
+
ADD VALUE 'value4' AFTER 'value2';
|
|
150
|
+
|
|
151
|
+
-- type.enum.comment
|
|
152
|
+
COMMENT ON TYPE public.test_enum IS
|
|
153
|
+
'enum comment';
|
|
154
|
+
|
|
155
|
+
-- type.enum.drop_comment
|
|
156
|
+
COMMENT ON TYPE public.test_enum IS NULL;
|
|
157
|
+
|
|
158
|
+
-- type.enum.grant
|
|
159
|
+
GRANT ALL ON TYPE public.test_enum TO
|
|
160
|
+
app_user;
|
|
161
|
+
|
|
162
|
+
-- type.enum.revoke
|
|
163
|
+
REVOKE ALL ON TYPE public.test_enum FROM
|
|
164
|
+
app_user;
|
|
165
|
+
|
|
166
|
+
-- type.enum.revoke_grant_option
|
|
167
|
+
REVOKE GRANT OPTION FOR ALL ON TYPE
|
|
168
|
+
public.test_enum FROM app_user;
|
|
169
|
+
|
|
170
|
+
-- type.composite.create
|
|
171
|
+
CREATE TYPE public.test_type AS (
|
|
172
|
+
id integer,
|
|
173
|
+
name text COLLATE "en_US"
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
-- type.composite.drop
|
|
177
|
+
DROP TYPE public.test_type;
|
|
178
|
+
|
|
179
|
+
-- type.composite.alter.change_owner
|
|
180
|
+
ALTER TYPE public.test_type OWNER TO
|
|
181
|
+
new_owner;
|
|
182
|
+
|
|
183
|
+
-- type.composite.alter.add_attribute
|
|
184
|
+
ALTER TYPE public.test_type
|
|
185
|
+
ADD ATTRIBUTE age integer;
|
|
186
|
+
|
|
187
|
+
-- type.composite.alter.drop_attribute
|
|
188
|
+
ALTER TYPE public.test_type DROP
|
|
189
|
+
ATTRIBUTE name;
|
|
190
|
+
|
|
191
|
+
-- type.composite.alter.alter_attr_type
|
|
192
|
+
ALTER TYPE public.test_type ALTER
|
|
193
|
+
ATTRIBUTE name TYPE varchar(255)
|
|
194
|
+
COLLATE "C";
|
|
195
|
+
|
|
196
|
+
-- type.composite.comment
|
|
197
|
+
COMMENT ON TYPE public.test_type IS
|
|
198
|
+
'composite comment';
|
|
199
|
+
|
|
200
|
+
-- type.composite.drop_comment
|
|
201
|
+
COMMENT ON TYPE public.test_type IS NULL;
|
|
202
|
+
|
|
203
|
+
-- type.composite.attr_comment
|
|
204
|
+
COMMENT ON COLUMN public.test_type.id IS
|
|
205
|
+
'attr comment';
|
|
206
|
+
|
|
207
|
+
-- type.composite.drop_attr_comment
|
|
208
|
+
COMMENT ON COLUMN public.test_type.id IS
|
|
209
|
+
NULL;
|
|
210
|
+
|
|
211
|
+
-- type.composite.grant
|
|
212
|
+
GRANT ALL ON TYPE public.test_type TO
|
|
213
|
+
app_user;
|
|
214
|
+
|
|
215
|
+
-- type.composite.revoke
|
|
216
|
+
REVOKE ALL ON TYPE public.test_type FROM
|
|
217
|
+
app_user;
|
|
218
|
+
|
|
219
|
+
-- type.composite.revoke_grant_option
|
|
220
|
+
REVOKE GRANT OPTION FOR ALL ON TYPE
|
|
221
|
+
public.test_type FROM app_user;
|
|
222
|
+
|
|
223
|
+
-- type.range.create
|
|
224
|
+
CREATE TYPE public.daterange_custom AS
|
|
225
|
+
RANGE (
|
|
226
|
+
SUBTYPE = date,
|
|
227
|
+
SUBTYPE_OPCLASS = public.date_ops,
|
|
228
|
+
COLLATION = "en_US",
|
|
229
|
+
CANONICAL = public.canon_fn,
|
|
230
|
+
SUBTYPE_DIFF = public.diff_fn
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
-- type.range.drop
|
|
234
|
+
DROP TYPE public.daterange_custom;
|
|
235
|
+
|
|
236
|
+
-- type.range.alter.change_owner
|
|
237
|
+
ALTER TYPE public.daterange_custom OWNER
|
|
238
|
+
TO new_owner;
|
|
239
|
+
|
|
240
|
+
-- type.range.comment
|
|
241
|
+
COMMENT ON TYPE public.daterange_custom
|
|
242
|
+
IS 'range comment';
|
|
243
|
+
|
|
244
|
+
-- type.range.drop_comment
|
|
245
|
+
COMMENT ON TYPE public.daterange_custom
|
|
246
|
+
IS NULL;
|
|
247
|
+
|
|
248
|
+
-- type.range.grant
|
|
249
|
+
GRANT ALL ON TYPE
|
|
250
|
+
public.daterange_custom TO app_user;
|
|
251
|
+
|
|
252
|
+
-- type.range.revoke
|
|
253
|
+
REVOKE ALL ON TYPE
|
|
254
|
+
public.daterange_custom FROM app_user;
|
|
255
|
+
|
|
256
|
+
-- type.range.revoke_grant_option
|
|
257
|
+
REVOKE GRANT OPTION FOR ALL ON TYPE
|
|
258
|
+
public.daterange_custom FROM app_user;
|
|
259
|
+
|
|
260
|
+
-- collation.create
|
|
261
|
+
CREATE COLLATION public.test (
|
|
262
|
+
LOCALE = 'en_US',
|
|
263
|
+
LC_COLLATE = 'en_US',
|
|
264
|
+
LC_CTYPE = 'en_US',
|
|
265
|
+
PROVIDER = icu,
|
|
266
|
+
DETERMINISTIC = false,
|
|
267
|
+
RULES = '& A < a <<< à',
|
|
268
|
+
VERSION = '1.0'
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
-- collation.drop
|
|
272
|
+
DROP COLLATION public.test;
|
|
273
|
+
|
|
274
|
+
-- collation.alter.change_owner
|
|
275
|
+
ALTER COLLATION public.test OWNER TO
|
|
276
|
+
new_owner;
|
|
277
|
+
|
|
278
|
+
-- collation.alter.refresh_version
|
|
279
|
+
ALTER COLLATION public.test REFRESH
|
|
280
|
+
VERSION;
|
|
281
|
+
|
|
282
|
+
-- collation.comment
|
|
283
|
+
COMMENT ON COLLATION public.test IS
|
|
284
|
+
'collation comment';
|
|
285
|
+
|
|
286
|
+
-- collation.drop_comment
|
|
287
|
+
COMMENT ON COLLATION public.test IS NULL;
|
|
288
|
+
|
|
289
|
+
-- table.create
|
|
290
|
+
CREATE TABLE
|
|
291
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test (
|
|
292
|
+
id bigint GENERATED
|
|
293
|
+
ALWAYS AS IDENTITY NOT NULL,
|
|
294
|
+
status text COLLATE "en_US"
|
|
295
|
+
DEFAULT 'pending',
|
|
296
|
+
created_at timestamptz DEFAULT now(),
|
|
297
|
+
ref_id bigint,
|
|
298
|
+
computed bigint GENERATED
|
|
299
|
+
ALWAYS AS (id * 2) STORED
|
|
300
|
+
)
|
|
301
|
+
WITH (fillfactor=70, autovacuum_enabled=false);
|
|
302
|
+
|
|
303
|
+
-- table.drop
|
|
304
|
+
DROP TABLE
|
|
305
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test;
|
|
306
|
+
|
|
307
|
+
-- table.alter.add_column
|
|
308
|
+
ALTER TABLE
|
|
309
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
310
|
+
ADD COLUMN email text COLLATE "en_US"
|
|
311
|
+
DEFAULT 'user@example.com' NOT NULL;
|
|
312
|
+
|
|
313
|
+
-- table.alter.drop_column
|
|
314
|
+
ALTER TABLE
|
|
315
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
316
|
+
DROP COLUMN computed;
|
|
317
|
+
|
|
318
|
+
-- table.alter.column_type
|
|
319
|
+
ALTER TABLE
|
|
320
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
321
|
+
ALTER COLUMN status TYPE character
|
|
322
|
+
varying(255) COLLATE "C";
|
|
323
|
+
|
|
324
|
+
-- table.alter.column_set_default
|
|
325
|
+
ALTER TABLE
|
|
326
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
327
|
+
ALTER COLUMN status
|
|
328
|
+
SET DEFAULT 'active';
|
|
329
|
+
|
|
330
|
+
-- table.alter.column_drop_default
|
|
331
|
+
ALTER TABLE
|
|
332
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
333
|
+
ALTER COLUMN status DROP DEFAULT;
|
|
334
|
+
|
|
335
|
+
-- table.alter.column_set_not_null
|
|
336
|
+
ALTER TABLE
|
|
337
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
338
|
+
ALTER COLUMN status SET NOT NULL;
|
|
339
|
+
|
|
340
|
+
-- table.alter.column_drop_not_null
|
|
341
|
+
ALTER TABLE
|
|
342
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
343
|
+
ALTER COLUMN status DROP NOT NULL;
|
|
344
|
+
|
|
345
|
+
-- table.alter.add_constraint
|
|
346
|
+
ALTER TABLE
|
|
347
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
348
|
+
ADD
|
|
349
|
+
CONSTRAINT uq_t_fmt_status UNIQUE
|
|
350
|
+
(status);
|
|
351
|
+
|
|
352
|
+
-- table.alter.add_fk_constraint
|
|
353
|
+
ALTER TABLE
|
|
354
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
355
|
+
ADD CONSTRAINT fk_t_fmt_ref
|
|
356
|
+
FOREIGN KEY (ref_id)
|
|
357
|
+
REFERENCES public.other_table(id)
|
|
358
|
+
MATCH FULL ON UPDATE SET NULL
|
|
359
|
+
ON DELETE CASCADE DEFERRABLE
|
|
360
|
+
INITIALLY DEFERRED;
|
|
361
|
+
|
|
362
|
+
-- table.alter.drop_constraint
|
|
363
|
+
ALTER TABLE
|
|
364
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
365
|
+
DROP CONSTRAINT uq_t_fmt_status;
|
|
366
|
+
|
|
367
|
+
-- table.alter.validate_constraint
|
|
368
|
+
ALTER TABLE
|
|
369
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
370
|
+
VALIDATE CONSTRAINT chk_t_fmt_status;
|
|
371
|
+
|
|
372
|
+
-- table.alter.change_owner
|
|
373
|
+
ALTER TABLE
|
|
374
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
375
|
+
OWNER TO new_owner;
|
|
376
|
+
|
|
377
|
+
-- table.alter.set_logged
|
|
378
|
+
ALTER TABLE
|
|
379
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
380
|
+
SET LOGGED;
|
|
381
|
+
|
|
382
|
+
-- table.alter.set_unlogged
|
|
383
|
+
ALTER TABLE
|
|
384
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
385
|
+
SET UNLOGGED;
|
|
386
|
+
|
|
387
|
+
-- table.alter.enable_rls
|
|
388
|
+
ALTER TABLE
|
|
389
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
390
|
+
ENABLE ROW LEVEL SECURITY;
|
|
391
|
+
|
|
392
|
+
-- table.alter.disable_rls
|
|
393
|
+
ALTER TABLE
|
|
394
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
395
|
+
DISABLE ROW LEVEL SECURITY;
|
|
396
|
+
|
|
397
|
+
-- table.alter.force_rls
|
|
398
|
+
ALTER TABLE
|
|
399
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
400
|
+
FORCE ROW LEVEL SECURITY;
|
|
401
|
+
|
|
402
|
+
-- table.alter.no_force_rls
|
|
403
|
+
ALTER TABLE
|
|
404
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
405
|
+
NO FORCE ROW LEVEL SECURITY;
|
|
406
|
+
|
|
407
|
+
-- table.alter.set_storage_params
|
|
408
|
+
ALTER TABLE
|
|
409
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
410
|
+
SET
|
|
411
|
+
(fillfactor=80,
|
|
412
|
+
autovacuum_enabled=true);
|
|
413
|
+
|
|
414
|
+
-- table.alter.reset_storage_params
|
|
415
|
+
ALTER TABLE
|
|
416
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
417
|
+
RESET (fillfactor, autovacuum_enabled);
|
|
418
|
+
|
|
419
|
+
-- table.alter.replica_identity
|
|
420
|
+
ALTER TABLE
|
|
421
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
422
|
+
REPLICA IDENTITY FULL;
|
|
423
|
+
|
|
424
|
+
-- table.alter.attach_partition
|
|
425
|
+
ALTER TABLE public.events
|
|
426
|
+
ATTACH PARTITION public.events_2024
|
|
427
|
+
FOR VALUES FROM ('2024-01-01') TO
|
|
428
|
+
('2025-01-01');
|
|
429
|
+
|
|
430
|
+
-- table.alter.detach_partition
|
|
431
|
+
ALTER TABLE public.events
|
|
432
|
+
DETACH PARTITION public.events_2024;
|
|
433
|
+
|
|
434
|
+
-- table.comment
|
|
435
|
+
COMMENT ON TABLE
|
|
436
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test IS 'table comment';
|
|
437
|
+
|
|
438
|
+
-- table.drop_comment
|
|
439
|
+
COMMENT ON TABLE
|
|
440
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test IS NULL;
|
|
441
|
+
|
|
442
|
+
-- table.column_comment
|
|
443
|
+
COMMENT ON COLUMN
|
|
444
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test.id IS 'id column';
|
|
445
|
+
|
|
446
|
+
-- table.drop_column_comment
|
|
447
|
+
COMMENT ON COLUMN
|
|
448
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test.id IS NULL;
|
|
449
|
+
|
|
450
|
+
-- table.constraint_comment
|
|
451
|
+
COMMENT ON CONSTRAINT pk_t_fmt
|
|
452
|
+
ON
|
|
453
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test IS 'primary key';
|
|
454
|
+
|
|
455
|
+
-- table.drop_constraint_comment
|
|
456
|
+
COMMENT ON CONSTRAINT chk_t_fmt_status
|
|
457
|
+
ON
|
|
458
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test IS NULL;
|
|
459
|
+
|
|
460
|
+
-- table.grant
|
|
461
|
+
GRANT INSERT,
|
|
462
|
+
SELECT
|
|
463
|
+
ON
|
|
464
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test TO app_reader;
|
|
465
|
+
|
|
466
|
+
-- table.revoke
|
|
467
|
+
REVOKE DELETE,
|
|
468
|
+
UPDATE
|
|
469
|
+
ON
|
|
470
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test FROM app_reader;
|
|
471
|
+
|
|
472
|
+
-- table.revoke_grant_option
|
|
473
|
+
REVOKE GRANT OPTION FOR INSERT,
|
|
474
|
+
SELECT
|
|
475
|
+
ON
|
|
476
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test FROM app_reader;
|
|
477
|
+
|
|
478
|
+
-- publication.create
|
|
479
|
+
CREATE PUBLICATION pub_custom FOR TABLE
|
|
480
|
+
public.articles_with_a_very_long_name_very_very_long_name_that_will_go_above_the_wrapping_limit (
|
|
481
|
+
id,
|
|
482
|
+
title
|
|
483
|
+
) WHERE (published = true),
|
|
484
|
+
TABLE
|
|
485
|
+
public.comments_a_little_smaller_name_than_the_previous_one, TABLES IN SCHEMA analytics;
|
|
486
|
+
|
|
487
|
+
-- publication.drop
|
|
488
|
+
DROP PUBLICATION pub_custom;
|
|
489
|
+
|
|
490
|
+
-- publication.alter.set_options
|
|
491
|
+
ALTER PUBLICATION pub_custom
|
|
492
|
+
SET
|
|
493
|
+
(publish =
|
|
494
|
+
'insert, update, delete, truncate',
|
|
495
|
+
publish_via_partition_root = false);
|
|
496
|
+
|
|
497
|
+
-- publication.alter.set_all_tables
|
|
498
|
+
ALTER PUBLICATION pub_custom
|
|
499
|
+
SET FOR ALL TABLES;
|
|
500
|
+
|
|
501
|
+
-- publication.alter.set_list
|
|
502
|
+
ALTER PUBLICATION pub_custom
|
|
503
|
+
SET TABLE
|
|
504
|
+
public.articles_with_a_very_long_name_very_very_long_name_that_will_go_above_the_wrapping_limit (id, title) WHERE (published = true), TABLE public.comments_a_little_smaller_name_than_the_previous_one, TABLES IN SCHEMA analytics;
|
|
505
|
+
|
|
506
|
+
-- publication.alter.add_tables
|
|
507
|
+
ALTER PUBLICATION pub_custom
|
|
508
|
+
ADD TABLE
|
|
509
|
+
public.new_table_with_very_long_name_for_formatting_and_wrapping_test;
|
|
510
|
+
|
|
511
|
+
-- publication.alter.drop_tables
|
|
512
|
+
ALTER
|
|
513
|
+
PUBLICATION pub_custom DROP TABLE
|
|
514
|
+
public.comments_a_little_smaller_name_than_the_previous_one;
|
|
515
|
+
|
|
516
|
+
-- publication.alter.add_schemas
|
|
517
|
+
ALTER PUBLICATION pub_custom
|
|
518
|
+
ADD TABLES IN SCHEMA staging;
|
|
519
|
+
|
|
520
|
+
-- publication.alter.drop_schemas
|
|
521
|
+
ALTER
|
|
522
|
+
PUBLICATION pub_custom DROP TABLES IN
|
|
523
|
+
SCHEMA analytics;
|
|
524
|
+
|
|
525
|
+
-- publication.alter.set_owner
|
|
526
|
+
ALTER
|
|
527
|
+
PUBLICATION pub_custom OWNER TO
|
|
528
|
+
new_owner;
|
|
529
|
+
|
|
530
|
+
-- publication.comment
|
|
531
|
+
COMMENT ON
|
|
532
|
+
PUBLICATION pub_custom IS
|
|
533
|
+
'publication comment';
|
|
534
|
+
|
|
535
|
+
-- publication.drop_comment
|
|
536
|
+
COMMENT ON
|
|
537
|
+
PUBLICATION pub_custom IS NULL;
|
|
538
|
+
|
|
539
|
+
-- view.create
|
|
540
|
+
CREATE VIEW public.test_view WITH (security_barrier=true, check_option=local) AS SELECT *
|
|
541
|
+
FROM test_table;
|
|
542
|
+
|
|
543
|
+
-- view.drop
|
|
544
|
+
DROP VIEW public.test_view;
|
|
545
|
+
|
|
546
|
+
-- view.alter.change_owner
|
|
547
|
+
ALTER VIEW public.test_view OWNER TO
|
|
548
|
+
new_owner;
|
|
549
|
+
|
|
550
|
+
-- view.alter.set_options
|
|
551
|
+
ALTER VIEW public.test_view
|
|
552
|
+
SET
|
|
553
|
+
(security_barrier=true,
|
|
554
|
+
check_option=cascaded);
|
|
555
|
+
|
|
556
|
+
-- view.alter.reset_options
|
|
557
|
+
ALTER VIEW public.test_view RESET
|
|
558
|
+
(security_barrier);
|
|
559
|
+
|
|
560
|
+
-- view.comment
|
|
561
|
+
COMMENT ON VIEW public.test_view IS
|
|
562
|
+
'view comment';
|
|
563
|
+
|
|
564
|
+
-- view.drop_comment
|
|
565
|
+
COMMENT ON VIEW public.test_view IS NULL;
|
|
566
|
+
|
|
567
|
+
-- view.grant
|
|
568
|
+
GRANT SELECT
|
|
569
|
+
ON public.test_view TO app_reader
|
|
570
|
+
WITH GRANT OPTION;
|
|
571
|
+
|
|
572
|
+
-- view.revoke
|
|
573
|
+
REVOKE SELECT
|
|
574
|
+
ON public.test_view FROM app_reader;
|
|
575
|
+
|
|
576
|
+
-- view.revoke_grant_option
|
|
577
|
+
REVOKE GRANT OPTION FOR SELECT
|
|
578
|
+
ON public.test_view FROM app_reader;
|
|
579
|
+
|
|
580
|
+
-- rule.create
|
|
581
|
+
CREATE RULE test_rule AS ON INSERT TO public.test_table DO INSTEAD NOTHING;
|
|
582
|
+
|
|
583
|
+
-- rule.drop
|
|
584
|
+
DROP RULE test_rule ON public.test_table;
|
|
585
|
+
|
|
586
|
+
-- rule.replace
|
|
587
|
+
CREATE OR REPLACE RULE test_rule AS ON INSERT TO public.test_table DO INSTEAD NOTHING;
|
|
588
|
+
|
|
589
|
+
-- rule.alter.set_enabled
|
|
590
|
+
ALTER TABLE public.test_table
|
|
591
|
+
DISABLE RULE test_rule;
|
|
592
|
+
|
|
593
|
+
-- rule.comment
|
|
594
|
+
COMMENT ON RULE test_rule
|
|
595
|
+
ON public.test_table IS
|
|
596
|
+
'rule comment';
|
|
597
|
+
|
|
598
|
+
-- rule.drop_comment
|
|
599
|
+
COMMENT ON RULE test_rule
|
|
600
|
+
ON public.test_table IS NULL;
|
|
601
|
+
|
|
602
|
+
-- procedure.create
|
|
603
|
+
CREATE PROCEDURE public.test_procedure()
|
|
604
|
+
LANGUAGE plpgsql
|
|
605
|
+
AS $$ begin null; end; $$;
|
|
606
|
+
|
|
607
|
+
-- procedure.drop
|
|
608
|
+
DROP PROCEDURE public.test_procedure();
|
|
609
|
+
|
|
610
|
+
-- function.create
|
|
611
|
+
CREATE FUNCTION
|
|
612
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name (
|
|
613
|
+
"p_schema_name_for_analytics" text,
|
|
614
|
+
"p_table_name_for_metrics" text,
|
|
615
|
+
"p_limit_count_default" integer
|
|
616
|
+
DEFAULT 100
|
|
617
|
+
)
|
|
618
|
+
RETURNS TABLE (
|
|
619
|
+
total bigint,
|
|
620
|
+
average numeric
|
|
621
|
+
)
|
|
622
|
+
LANGUAGE plpgsql
|
|
623
|
+
STABLE
|
|
624
|
+
SECURITY DEFINER
|
|
625
|
+
PARALLEL SAFE
|
|
626
|
+
COST 100
|
|
627
|
+
ROWS 10
|
|
628
|
+
STRICT
|
|
629
|
+
SET search_path TO 'pg_catalog',
|
|
630
|
+
'public'
|
|
631
|
+
AS $function$ BEGIN RETURN QUERY SELECT count(*)::bigint, avg(value)::numeric FROM generate_series(1, p_limit_count_default); END; $function$;
|
|
632
|
+
|
|
633
|
+
-- function.drop
|
|
634
|
+
DROP FUNCTION
|
|
635
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name(IN "p_schema_name_for_analytics" text, IN "p_table_name_for_metrics" text, IN "p_limit_count_default" integer);
|
|
636
|
+
|
|
637
|
+
-- function.alter.change_owner
|
|
638
|
+
ALTER FUNCTION
|
|
639
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name OWNER TO new_admin;
|
|
640
|
+
|
|
641
|
+
-- function.alter.set_security
|
|
642
|
+
ALTER FUNCTION
|
|
643
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name SECURITY INVOKER;
|
|
644
|
+
|
|
645
|
+
-- function.alter.set_config
|
|
646
|
+
ALTER FUNCTION
|
|
647
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name SET work_mem TO '256MB';
|
|
648
|
+
|
|
649
|
+
-- function.alter.set_volatility
|
|
650
|
+
ALTER FUNCTION
|
|
651
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name IMMUTABLE;
|
|
652
|
+
|
|
653
|
+
-- function.alter.set_strictness
|
|
654
|
+
ALTER FUNCTION
|
|
655
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name CALLED ON NULL INPUT;
|
|
656
|
+
|
|
657
|
+
-- function.alter.set_leakproof
|
|
658
|
+
ALTER FUNCTION
|
|
659
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name LEAKPROOF;
|
|
660
|
+
|
|
661
|
+
-- function.alter.set_parallel
|
|
662
|
+
ALTER FUNCTION
|
|
663
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name PARALLEL RESTRICTED;
|
|
664
|
+
|
|
665
|
+
-- function.comment
|
|
666
|
+
COMMENT ON FUNCTION
|
|
667
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name(text,text,integer) IS 'Calculate metrics for a given table';
|
|
668
|
+
|
|
669
|
+
-- function.drop_comment
|
|
670
|
+
COMMENT ON FUNCTION
|
|
671
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name(text,text,integer) IS NULL;
|
|
672
|
+
|
|
673
|
+
-- function.grant
|
|
674
|
+
GRANT ALL ON FUNCTION
|
|
675
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name(text, text, integer) TO app_user WITH GRANT OPTION;
|
|
676
|
+
|
|
677
|
+
-- function.revoke
|
|
678
|
+
REVOKE ALL ON FUNCTION
|
|
679
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name(text, text, integer) FROM app_user;
|
|
680
|
+
|
|
681
|
+
-- function.revoke_grant_option
|
|
682
|
+
REVOKE GRANT OPTION FOR ALL ON FUNCTION
|
|
683
|
+
public.calculate_metrics_for_analytics_dashboard_with_extended_name(text, text, integer) FROM app_user;
|
|
684
|
+
|
|
685
|
+
-- sequence.create
|
|
686
|
+
CREATE SEQUENCE
|
|
687
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test_id_seq;
|
|
688
|
+
|
|
689
|
+
-- sequence.drop
|
|
690
|
+
DROP SEQUENCE
|
|
691
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test_id_seq;
|
|
692
|
+
|
|
693
|
+
-- sequence.alter.set_owned_by
|
|
694
|
+
ALTER SEQUENCE
|
|
695
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test_id_seq OWNED BY public.table_with_very_long_name_for_formatting_and_wrapping_test.id;
|
|
696
|
+
|
|
697
|
+
-- sequence.alter.set_options
|
|
698
|
+
ALTER SEQUENCE
|
|
699
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test_id_seq INCREMENT BY 10 MINVALUE 1 MAXVALUE 1000000 CACHE 5 CYCLE;
|
|
700
|
+
|
|
701
|
+
-- sequence.comment
|
|
702
|
+
COMMENT ON SEQUENCE
|
|
703
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test_id_seq IS 'sequence for table_with_very_long_name_for_formatting_and_wrapping_test.id';
|
|
704
|
+
|
|
705
|
+
-- sequence.drop_comment
|
|
706
|
+
COMMENT ON SEQUENCE
|
|
707
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test_id_seq IS NULL;
|
|
708
|
+
|
|
709
|
+
-- sequence.grant
|
|
710
|
+
GRANT SELECT,
|
|
711
|
+
USAGE
|
|
712
|
+
ON SEQUENCE
|
|
713
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test_id_seq TO app_user;
|
|
714
|
+
|
|
715
|
+
-- sequence.revoke
|
|
716
|
+
REVOKE USAGE
|
|
717
|
+
ON SEQUENCE
|
|
718
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test_id_seq FROM app_user;
|
|
719
|
+
|
|
720
|
+
-- sequence.revoke_grant_option
|
|
721
|
+
REVOKE GRANT OPTION FOR USAGE
|
|
722
|
+
ON SEQUENCE
|
|
723
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test_id_seq FROM app_user;
|
|
724
|
+
|
|
725
|
+
-- policy.create
|
|
726
|
+
CREATE POLICY allow_select_own
|
|
727
|
+
ON
|
|
728
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
729
|
+
FOR SELECT
|
|
730
|
+
TO authenticated
|
|
731
|
+
USING (auth.uid() = user_id);
|
|
732
|
+
|
|
733
|
+
-- policy.create_restrictive
|
|
734
|
+
CREATE POLICY restrict_delete
|
|
735
|
+
ON
|
|
736
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test
|
|
737
|
+
AS RESTRICTIVE
|
|
738
|
+
FOR DELETE
|
|
739
|
+
TO authenticated, service_role
|
|
740
|
+
USING (auth.uid() = owner_id)
|
|
741
|
+
WITH CHECK (status <> 'locked');
|
|
742
|
+
|
|
743
|
+
-- policy.drop
|
|
744
|
+
DROP POLICY allow_select_own
|
|
745
|
+
ON
|
|
746
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test;
|
|
747
|
+
|
|
748
|
+
-- policy.alter.set_roles
|
|
749
|
+
ALTER POLICY public.allow_select_own
|
|
750
|
+
ON
|
|
751
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test TO authenticated, anon;
|
|
752
|
+
|
|
753
|
+
-- policy.alter.set_using
|
|
754
|
+
ALTER POLICY public.allow_select_own
|
|
755
|
+
ON
|
|
756
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test USING (auth.uid() = user_id AND status = 'active');
|
|
757
|
+
|
|
758
|
+
-- policy.alter.set_with_check
|
|
759
|
+
ALTER POLICY public.allow_select_own
|
|
760
|
+
ON
|
|
761
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test WITH CHECK (auth.uid() = user_id);
|
|
762
|
+
|
|
763
|
+
-- policy.comment
|
|
764
|
+
COMMENT ON POLICY allow_select_own
|
|
765
|
+
ON
|
|
766
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test IS 'rls policy comment';
|
|
767
|
+
|
|
768
|
+
-- policy.drop_comment
|
|
769
|
+
COMMENT ON POLICY allow_select_own
|
|
770
|
+
ON
|
|
771
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test IS NULL;
|
|
772
|
+
|
|
773
|
+
-- index.create
|
|
774
|
+
CREATE UNIQUE INDEX idx_t_fmt_status
|
|
775
|
+
ON
|
|
776
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test (status)
|
|
777
|
+
WITH (fillfactor='90')
|
|
778
|
+
WHERE (status <> 'archived'::text);
|
|
779
|
+
|
|
780
|
+
-- index.create_gin
|
|
781
|
+
CREATE INDEX idx_t_fmt_search
|
|
782
|
+
ON
|
|
783
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test USING gin (to_tsvector('english'::regconfig, status));
|
|
784
|
+
|
|
785
|
+
-- index.drop
|
|
786
|
+
DROP INDEX public.idx_t_fmt_status;
|
|
787
|
+
|
|
788
|
+
-- index.alter.set_storage_params
|
|
789
|
+
ALTER INDEX public.idx_t_fmt_status
|
|
790
|
+
RESET (deduplicate_items);
|
|
791
|
+
|
|
792
|
+
ALTER INDEX public.idx_t_fmt_status
|
|
793
|
+
SET (fillfactor=80);
|
|
794
|
+
|
|
795
|
+
-- index.alter.set_statistics
|
|
796
|
+
ALTER INDEX public.idx_t_fmt_status
|
|
797
|
+
ALTER COLUMN 1 SET STATISTICS 500;
|
|
798
|
+
|
|
799
|
+
-- index.comment
|
|
800
|
+
COMMENT ON INDEX public.idx_t_fmt_status
|
|
801
|
+
IS 'index comment';
|
|
802
|
+
|
|
803
|
+
-- index.drop_comment
|
|
804
|
+
COMMENT ON INDEX public.idx_t_fmt_status
|
|
805
|
+
IS NULL;
|
|
806
|
+
|
|
807
|
+
-- trigger.create
|
|
808
|
+
CREATE TRIGGER trg_audit AFTER INSERT OR
|
|
809
|
+
UPDATE
|
|
810
|
+
ON
|
|
811
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test REFERENCING OLD TABLE AS old_rows NEW TABLE AS new_rows FOR EACH ROW WHEN (
|
|
812
|
+
(NEW.status IS DISTINCT FROM
|
|
813
|
+
OLD.status)
|
|
814
|
+
) EXECUTE FUNCTION
|
|
815
|
+
public.audit_trigger_fn('arg1',
|
|
816
|
+
'arg2');
|
|
817
|
+
|
|
818
|
+
-- trigger.drop
|
|
819
|
+
DROP TRIGGER trg_audit
|
|
820
|
+
ON
|
|
821
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test;
|
|
822
|
+
|
|
823
|
+
-- trigger.replace
|
|
824
|
+
CREATE OR REPLACE TRIGGER trg_audit
|
|
825
|
+
AFTER INSERT OR UPDATE
|
|
826
|
+
ON
|
|
827
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test REFERENCING OLD TABLE AS old_rows NEW TABLE AS new_rows FOR EACH ROW WHEN (
|
|
828
|
+
(NEW.status IS DISTINCT FROM
|
|
829
|
+
OLD.status)
|
|
830
|
+
) EXECUTE FUNCTION
|
|
831
|
+
public.audit_trigger_fn('arg1',
|
|
832
|
+
'arg2');
|
|
833
|
+
|
|
834
|
+
-- trigger.comment
|
|
835
|
+
COMMENT ON TRIGGER trg_audit
|
|
836
|
+
ON
|
|
837
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test IS 'trigger comment';
|
|
838
|
+
|
|
839
|
+
-- trigger.drop_comment
|
|
840
|
+
COMMENT ON TRIGGER trg_audit
|
|
841
|
+
ON
|
|
842
|
+
public.table_with_very_long_name_for_formatting_and_wrapping_test IS NULL;
|
|
843
|
+
|
|
844
|
+
-- matview.create
|
|
845
|
+
CREATE MATERIALIZED VIEW
|
|
846
|
+
analytics.daily_stats
|
|
847
|
+
WITH (fillfactor=70)
|
|
848
|
+
AS SELECT date_trunc('day', created_at) AS day, count(*) AS total
|
|
849
|
+
FROM public.events
|
|
850
|
+
GROUP BY 1 WITH DATA;
|
|
851
|
+
|
|
852
|
+
-- matview.drop
|
|
853
|
+
DROP MATERIALIZED VIEW
|
|
854
|
+
analytics.daily_stats;
|
|
855
|
+
|
|
856
|
+
-- matview.alter.change_owner
|
|
857
|
+
ALTER MATERIALIZED VIEW
|
|
858
|
+
analytics.daily_stats
|
|
859
|
+
OWNER TO new_owner;
|
|
860
|
+
|
|
861
|
+
-- matview.alter.set_storage
|
|
862
|
+
ALTER MATERIALIZED VIEW
|
|
863
|
+
analytics.daily_stats
|
|
864
|
+
RESET (autovacuum_enabled);
|
|
865
|
+
|
|
866
|
+
ALTER MATERIALIZED VIEW
|
|
867
|
+
analytics.daily_stats
|
|
868
|
+
SET (fillfactor=80);
|
|
869
|
+
|
|
870
|
+
-- matview.comment
|
|
871
|
+
COMMENT ON MATERIALIZED VIEW
|
|
872
|
+
analytics.daily_stats IS
|
|
873
|
+
'daily aggregation';
|
|
874
|
+
|
|
875
|
+
-- matview.drop_comment
|
|
876
|
+
COMMENT ON MATERIALIZED VIEW
|
|
877
|
+
analytics.daily_stats IS NULL;
|
|
878
|
+
|
|
879
|
+
-- matview.column_comment
|
|
880
|
+
COMMENT ON COLUMN
|
|
881
|
+
analytics.daily_stats.day IS
|
|
882
|
+
'day bucket';
|
|
883
|
+
|
|
884
|
+
-- matview.drop_column_comment
|
|
885
|
+
COMMENT ON COLUMN
|
|
886
|
+
analytics.daily_stats.day IS NULL;
|
|
887
|
+
|
|
888
|
+
-- matview.grant
|
|
889
|
+
GRANT SELECT
|
|
890
|
+
ON analytics.daily_stats TO app_reader;
|
|
891
|
+
|
|
892
|
+
-- matview.revoke
|
|
893
|
+
REVOKE SELECT
|
|
894
|
+
ON analytics.daily_stats FROM
|
|
895
|
+
app_reader;
|
|
896
|
+
|
|
897
|
+
-- matview.revoke_grant_option
|
|
898
|
+
REVOKE GRANT OPTION FOR SELECT
|
|
899
|
+
ON analytics.daily_stats FROM
|
|
900
|
+
app_reader;
|
|
901
|
+
|
|
902
|
+
-- aggregate.create
|
|
903
|
+
CREATE AGGREGATE
|
|
904
|
+
public.array_cat_agg(anycompatiblearray) (
|
|
905
|
+
SFUNC = array_cat,
|
|
906
|
+
STYPE = anycompatiblearray,
|
|
907
|
+
COMBINEFUNC = array_cat,
|
|
908
|
+
INITCOND = '{}',
|
|
909
|
+
PARALLEL SAFE,
|
|
910
|
+
STRICT
|
|
911
|
+
);
|
|
912
|
+
|
|
913
|
+
-- aggregate.drop
|
|
914
|
+
DROP AGGREGATE
|
|
915
|
+
public.array_cat_agg(anycompatiblearray);
|
|
916
|
+
|
|
917
|
+
-- aggregate.alter.change_owner
|
|
918
|
+
ALTER AGGREGATE
|
|
919
|
+
public.array_cat_agg(anycompatiblearray) OWNER TO new_owner;
|
|
920
|
+
|
|
921
|
+
-- aggregate.comment
|
|
922
|
+
COMMENT ON AGGREGATE
|
|
923
|
+
public.array_cat_agg(anycompatiblearray) IS 'concatenate arrays aggregate';
|
|
924
|
+
|
|
925
|
+
-- aggregate.drop_comment
|
|
926
|
+
COMMENT ON AGGREGATE
|
|
927
|
+
public.array_cat_agg(anycompatiblearray) IS NULL;
|
|
928
|
+
|
|
929
|
+
-- aggregate.grant
|
|
930
|
+
GRANT ALL ON FUNCTION
|
|
931
|
+
public.array_cat_agg(anycompatiblearray) TO app_user;
|
|
932
|
+
|
|
933
|
+
-- aggregate.revoke
|
|
934
|
+
REVOKE ALL ON FUNCTION
|
|
935
|
+
public.array_cat_agg(anycompatiblearray) FROM app_user;
|
|
936
|
+
|
|
937
|
+
-- aggregate.revoke_grant_option
|
|
938
|
+
REVOKE GRANT OPTION FOR ALL ON FUNCTION
|
|
939
|
+
public.array_cat_agg(anycompatiblearray) FROM app_user;
|
|
940
|
+
|
|
941
|
+
-- event_trigger.create
|
|
942
|
+
CREATE EVENT TRIGGER prevent_drop
|
|
943
|
+
ON sql_drop
|
|
944
|
+
WHEN TAG IN
|
|
945
|
+
('DROP TABLE', 'DROP SCHEMA')
|
|
946
|
+
EXECUTE FUNCTION
|
|
947
|
+
public.prevent_drop_fn();
|
|
948
|
+
|
|
949
|
+
-- event_trigger.drop
|
|
950
|
+
DROP EVENT TRIGGER prevent_drop;
|
|
951
|
+
|
|
952
|
+
-- event_trigger.alter.change_owner
|
|
953
|
+
ALTER EVENT TRIGGER prevent_drop
|
|
954
|
+
OWNER TO new_owner;
|
|
955
|
+
|
|
956
|
+
-- event_trigger.alter.set_enabled
|
|
957
|
+
ALTER EVENT TRIGGER prevent_drop
|
|
958
|
+
DISABLE;
|
|
959
|
+
|
|
960
|
+
-- event_trigger.comment
|
|
961
|
+
COMMENT ON EVENT TRIGGER prevent_drop IS
|
|
962
|
+
'prevent accidental drops';
|
|
963
|
+
|
|
964
|
+
-- event_trigger.drop_comment
|
|
965
|
+
COMMENT ON EVENT TRIGGER prevent_drop IS
|
|
966
|
+
NULL;
|
|
967
|
+
|
|
968
|
+
-- language.create
|
|
969
|
+
CREATE TRUSTED LANGUAGE plv8
|
|
970
|
+
HANDLER plv8_call_handler
|
|
971
|
+
INLINE plv8_inline_handler
|
|
972
|
+
VALIDATOR plv8_call_validator;
|
|
973
|
+
|
|
974
|
+
-- language.drop
|
|
975
|
+
DROP LANGUAGE plv8;
|
|
976
|
+
|
|
977
|
+
-- language.alter.change_owner
|
|
978
|
+
ALTER LANGUAGE plv8 OWNER TO new_owner;
|
|
979
|
+
|
|
980
|
+
-- language.comment
|
|
981
|
+
COMMENT ON LANGUAGE plv8 IS
|
|
982
|
+
'PL/V8 trusted procedural language';
|
|
983
|
+
|
|
984
|
+
-- language.drop_comment
|
|
985
|
+
COMMENT ON LANGUAGE plv8 IS NULL;
|
|
986
|
+
|
|
987
|
+
-- language.grant
|
|
988
|
+
GRANT ALL ON LANGUAGE plv8 TO app_user
|
|
989
|
+
WITH GRANT OPTION;
|
|
990
|
+
|
|
991
|
+
-- language.revoke
|
|
992
|
+
REVOKE ALL ON LANGUAGE plv8 FROM
|
|
993
|
+
app_user;
|
|
994
|
+
|
|
995
|
+
-- language.revoke_grant_option
|
|
996
|
+
REVOKE GRANT OPTION FOR ALL ON LANGUAGE
|
|
997
|
+
plv8 FROM app_user;
|
|
998
|
+
|
|
999
|
+
-- role.create
|
|
1000
|
+
CREATE ROLE app_user WITH LOGIN
|
|
1001
|
+
CONNECTION LIMIT 100;
|
|
1002
|
+
|
|
1003
|
+
-- role.drop
|
|
1004
|
+
DROP ROLE app_user;
|
|
1005
|
+
|
|
1006
|
+
-- role.alter.set_options
|
|
1007
|
+
ALTER ROLE app_user
|
|
1008
|
+
WITH NOSUPERUSER CREATEDB;
|
|
1009
|
+
|
|
1010
|
+
-- role.alter.set_config
|
|
1011
|
+
ALTER ROLE app_user
|
|
1012
|
+
SET statement_timeout TO '60000';
|
|
1013
|
+
|
|
1014
|
+
-- role.comment
|
|
1015
|
+
COMMENT ON ROLE app_user IS
|
|
1016
|
+
'application user role';
|
|
1017
|
+
|
|
1018
|
+
-- role.drop_comment
|
|
1019
|
+
COMMENT ON ROLE app_user IS NULL;
|
|
1020
|
+
|
|
1021
|
+
-- role.grant_membership
|
|
1022
|
+
GRANT app_user TO dev_user
|
|
1023
|
+
WITH ADMIN OPTION;
|
|
1024
|
+
|
|
1025
|
+
-- role.revoke_membership
|
|
1026
|
+
REVOKE app_user FROM dev_user;
|
|
1027
|
+
|
|
1028
|
+
-- role.revoke_membership_options
|
|
1029
|
+
REVOKE ADMIN OPTION FOR app_user FROM
|
|
1030
|
+
dev_user;
|
|
1031
|
+
|
|
1032
|
+
-- role.grant_default_privileges
|
|
1033
|
+
ALTER DEFAULT PRIVILEGES FOR ROLE
|
|
1034
|
+
app_user IN SCHEMA public GRANT SELECT
|
|
1035
|
+
ON TABLES TO app_reader;
|
|
1036
|
+
|
|
1037
|
+
-- role.revoke_default_privileges
|
|
1038
|
+
ALTER DEFAULT PRIVILEGES FOR ROLE
|
|
1039
|
+
app_user IN SCHEMA public REVOKE
|
|
1040
|
+
SELECT ON TABLES FROM app_reader;
|
|
1041
|
+
|
|
1042
|
+
-- subscription.create
|
|
1043
|
+
CREATE SUBSCRIPTION sub_replica
|
|
1044
|
+
CONNECTION
|
|
1045
|
+
'host=primary.db port=5432 dbname=mydb'
|
|
1046
|
+
PUBLICATION pub_custom
|
|
1047
|
+
WITH (
|
|
1048
|
+
slot_name =
|
|
1049
|
+
'sub_replica_slot',
|
|
1050
|
+
binary = true,
|
|
1051
|
+
streaming = 'parallel',
|
|
1052
|
+
synchronous_commit = 'remote_apply',
|
|
1053
|
+
disable_on_error = true,
|
|
1054
|
+
failover = true
|
|
1055
|
+
);
|
|
1056
|
+
|
|
1057
|
+
-- subscription.drop
|
|
1058
|
+
DROP SUBSCRIPTION sub_replica;
|
|
1059
|
+
|
|
1060
|
+
-- subscription.alter.set_connection
|
|
1061
|
+
ALTER SUBSCRIPTION sub_replica
|
|
1062
|
+
CONNECTION
|
|
1063
|
+
'host=primary.db port=5432 dbname=mydb';
|
|
1064
|
+
|
|
1065
|
+
-- subscription.alter.set_publication
|
|
1066
|
+
ALTER SUBSCRIPTION sub_replica
|
|
1067
|
+
SET PUBLICATION pub_custom;
|
|
1068
|
+
|
|
1069
|
+
-- subscription.alter.enable
|
|
1070
|
+
ALTER SUBSCRIPTION sub_replica
|
|
1071
|
+
ENABLE;
|
|
1072
|
+
|
|
1073
|
+
-- subscription.alter.disable
|
|
1074
|
+
ALTER SUBSCRIPTION sub_replica
|
|
1075
|
+
DISABLE;
|
|
1076
|
+
|
|
1077
|
+
-- subscription.alter.set_options
|
|
1078
|
+
ALTER SUBSCRIPTION sub_replica
|
|
1079
|
+
SET (
|
|
1080
|
+
binary = true,
|
|
1081
|
+
streaming = 'parallel',
|
|
1082
|
+
synchronous_commit = 'remote_apply'
|
|
1083
|
+
);
|
|
1084
|
+
|
|
1085
|
+
-- subscription.alter.set_owner
|
|
1086
|
+
ALTER SUBSCRIPTION sub_replica
|
|
1087
|
+
OWNER TO new_owner;
|
|
1088
|
+
|
|
1089
|
+
-- subscription.comment
|
|
1090
|
+
COMMENT ON SUBSCRIPTION sub_replica IS
|
|
1091
|
+
'replication subscription';
|
|
1092
|
+
|
|
1093
|
+
-- subscription.drop_comment
|
|
1094
|
+
COMMENT ON SUBSCRIPTION sub_replica IS
|
|
1095
|
+
NULL;
|
|
1096
|
+
|
|
1097
|
+
-- fdw.create
|
|
1098
|
+
CREATE FOREIGN DATA WRAPPER postgres_fdw
|
|
1099
|
+
HANDLER postgres_fdw_handler
|
|
1100
|
+
VALIDATOR postgres_fdw_validator
|
|
1101
|
+
OPTIONS (debug 'true');
|
|
1102
|
+
|
|
1103
|
+
-- fdw.drop
|
|
1104
|
+
DROP FOREIGN DATA WRAPPER postgres_fdw;
|
|
1105
|
+
|
|
1106
|
+
-- fdw.alter.change_owner
|
|
1107
|
+
ALTER FOREIGN DATA WRAPPER postgres_fdw
|
|
1108
|
+
OWNER TO new_owner;
|
|
1109
|
+
|
|
1110
|
+
-- fdw.alter.set_options
|
|
1111
|
+
ALTER FOREIGN DATA WRAPPER postgres_fdw
|
|
1112
|
+
OPTIONS (
|
|
1113
|
+
SET debug 'false',
|
|
1114
|
+
ADD use_remote_estimate ''
|
|
1115
|
+
);
|
|
1116
|
+
|
|
1117
|
+
-- fdw.comment
|
|
1118
|
+
COMMENT ON
|
|
1119
|
+
FOREIGN DATA WRAPPER postgres_fdw IS
|
|
1120
|
+
'PostgreSQL foreign data wrapper';
|
|
1121
|
+
|
|
1122
|
+
-- fdw.drop_comment
|
|
1123
|
+
COMMENT ON
|
|
1124
|
+
FOREIGN DATA WRAPPER postgres_fdw IS
|
|
1125
|
+
NULL;
|
|
1126
|
+
|
|
1127
|
+
-- fdw.grant
|
|
1128
|
+
GRANT ALL ON
|
|
1129
|
+
FOREIGN DATA WRAPPER postgres_fdw TO
|
|
1130
|
+
app_user;
|
|
1131
|
+
|
|
1132
|
+
-- fdw.revoke
|
|
1133
|
+
REVOKE ALL ON
|
|
1134
|
+
FOREIGN DATA WRAPPER postgres_fdw FROM
|
|
1135
|
+
app_user;
|
|
1136
|
+
|
|
1137
|
+
-- fdw.revoke_grant_option
|
|
1138
|
+
REVOKE GRANT OPTION FOR ALL ON
|
|
1139
|
+
FOREIGN DATA WRAPPER postgres_fdw FROM
|
|
1140
|
+
app_user;
|
|
1141
|
+
|
|
1142
|
+
-- foreign_table.create
|
|
1143
|
+
CREATE
|
|
1144
|
+
FOREIGN TABLE public.remote_users (
|
|
1145
|
+
id integer,
|
|
1146
|
+
email text
|
|
1147
|
+
) SERVER remote_server
|
|
1148
|
+
OPTIONS
|
|
1149
|
+
(schema_name 'public', table_name
|
|
1150
|
+
'users');
|
|
1151
|
+
|
|
1152
|
+
-- foreign_table.drop
|
|
1153
|
+
DROP FOREIGN TABLE public.remote_users;
|
|
1154
|
+
|
|
1155
|
+
-- foreign_table.alter.change_owner
|
|
1156
|
+
ALTER FOREIGN TABLE public.remote_users
|
|
1157
|
+
OWNER TO new_owner;
|
|
1158
|
+
|
|
1159
|
+
-- foreign_table.alter.add_column
|
|
1160
|
+
ALTER FOREIGN TABLE public.remote_users
|
|
1161
|
+
ADD COLUMN name text
|
|
1162
|
+
NOT NULL DEFAULT 'unknown';
|
|
1163
|
+
|
|
1164
|
+
-- foreign_table.alter.drop_column
|
|
1165
|
+
ALTER FOREIGN TABLE public.remote_users
|
|
1166
|
+
DROP COLUMN email;
|
|
1167
|
+
|
|
1168
|
+
-- foreign_table.alter.column_type
|
|
1169
|
+
ALTER FOREIGN TABLE public.remote_users
|
|
1170
|
+
ALTER COLUMN id TYPE bigint;
|
|
1171
|
+
|
|
1172
|
+
-- foreign_table.alter.column_set_default
|
|
1173
|
+
ALTER FOREIGN TABLE public.remote_users
|
|
1174
|
+
ALTER COLUMN email
|
|
1175
|
+
SET DEFAULT 'nobody@example.com';
|
|
1176
|
+
|
|
1177
|
+
-- foreign_table.alter.column_drop_default
|
|
1178
|
+
ALTER FOREIGN TABLE public.remote_users
|
|
1179
|
+
ALTER COLUMN email DROP DEFAULT;
|
|
1180
|
+
|
|
1181
|
+
-- foreign_table.alter.column_set_not_null
|
|
1182
|
+
ALTER FOREIGN TABLE public.remote_users
|
|
1183
|
+
ALTER COLUMN email SET NOT NULL;
|
|
1184
|
+
|
|
1185
|
+
-- foreign_table.alter.column_drop_not_null
|
|
1186
|
+
ALTER FOREIGN TABLE public.remote_users
|
|
1187
|
+
ALTER COLUMN email DROP NOT NULL;
|
|
1188
|
+
|
|
1189
|
+
-- foreign_table.alter.set_options
|
|
1190
|
+
ALTER FOREIGN TABLE public.remote_users
|
|
1191
|
+
OPTIONS (SET fetch_size '1000');
|
|
1192
|
+
|
|
1193
|
+
-- foreign_table.comment
|
|
1194
|
+
COMMENT ON
|
|
1195
|
+
FOREIGN TABLE public.remote_users IS
|
|
1196
|
+
'remote users table';
|
|
1197
|
+
|
|
1198
|
+
-- foreign_table.drop_comment
|
|
1199
|
+
COMMENT ON
|
|
1200
|
+
FOREIGN TABLE public.remote_users IS
|
|
1201
|
+
NULL;
|
|
1202
|
+
|
|
1203
|
+
-- foreign_table.grant
|
|
1204
|
+
GRANT SELECT ON
|
|
1205
|
+
FOREIGN TABLE public.remote_users TO
|
|
1206
|
+
app_reader;
|
|
1207
|
+
|
|
1208
|
+
-- foreign_table.revoke
|
|
1209
|
+
REVOKE SELECT ON
|
|
1210
|
+
FOREIGN TABLE public.remote_users FROM
|
|
1211
|
+
app_reader;
|
|
1212
|
+
|
|
1213
|
+
-- foreign_table.revoke_grant_option
|
|
1214
|
+
REVOKE GRANT OPTION FOR SELECT ON
|
|
1215
|
+
FOREIGN TABLE public.remote_users FROM
|
|
1216
|
+
app_reader;
|
|
1217
|
+
|
|
1218
|
+
-- server.create
|
|
1219
|
+
CREATE SERVER remote_server
|
|
1220
|
+
TYPE 'postgresql'
|
|
1221
|
+
VERSION '16.0'
|
|
1222
|
+
FOREIGN DATA WRAPPER postgres_fdw
|
|
1223
|
+
OPTIONS (
|
|
1224
|
+
host 'remote.host',
|
|
1225
|
+
port '5432',
|
|
1226
|
+
dbname 'remote_db'
|
|
1227
|
+
);
|
|
1228
|
+
|
|
1229
|
+
-- server.drop
|
|
1230
|
+
DROP SERVER remote_server;
|
|
1231
|
+
|
|
1232
|
+
-- server.alter.change_owner
|
|
1233
|
+
ALTER SERVER remote_server
|
|
1234
|
+
OWNER TO new_owner;
|
|
1235
|
+
|
|
1236
|
+
-- server.alter.set_version
|
|
1237
|
+
ALTER SERVER remote_server
|
|
1238
|
+
VERSION '17.0';
|
|
1239
|
+
|
|
1240
|
+
-- server.alter.set_options
|
|
1241
|
+
ALTER SERVER remote_server
|
|
1242
|
+
OPTIONS (
|
|
1243
|
+
SET host 'new.host',
|
|
1244
|
+
DROP port
|
|
1245
|
+
);
|
|
1246
|
+
|
|
1247
|
+
-- server.comment
|
|
1248
|
+
COMMENT ON SERVER remote_server IS
|
|
1249
|
+
'remote PostgreSQL server';
|
|
1250
|
+
|
|
1251
|
+
-- server.drop_comment
|
|
1252
|
+
COMMENT ON SERVER remote_server IS NULL;
|
|
1253
|
+
|
|
1254
|
+
-- server.grant
|
|
1255
|
+
GRANT ALL ON SERVER remote_server TO
|
|
1256
|
+
app_user;
|
|
1257
|
+
|
|
1258
|
+
-- server.revoke
|
|
1259
|
+
REVOKE ALL ON SERVER remote_server FROM
|
|
1260
|
+
app_user;
|
|
1261
|
+
|
|
1262
|
+
-- server.revoke_grant_option
|
|
1263
|
+
REVOKE GRANT OPTION FOR ALL ON SERVER
|
|
1264
|
+
remote_server FROM app_user;
|
|
1265
|
+
|
|
1266
|
+
-- user_mapping.create
|
|
1267
|
+
CREATE USER MAPPING FOR app_user SERVER
|
|
1268
|
+
remote_server
|
|
1269
|
+
OPTIONS
|
|
1270
|
+
(user 'remote_app', password
|
|
1271
|
+
'secret123');
|
|
1272
|
+
|
|
1273
|
+
-- user_mapping.drop
|
|
1274
|
+
DROP USER MAPPING FOR app_user SERVER
|
|
1275
|
+
remote_server;
|
|
1276
|
+
|
|
1277
|
+
-- user_mapping.alter.set_options
|
|
1278
|
+
ALTER USER MAPPING FOR app_user SERVER
|
|
1279
|
+
remote_server
|
|
1280
|
+
OPTIONS (SET password 'new_secret');"
|
|
1281
|
+
`);
|
|
1282
|
+
});
|
|
1283
|
+
});
|