Last active
October 9, 2016 13:44
-
-
Save deinspanjer/06f014142b1aa5d0135ea9c90d05e984 to your computer and use it in GitHub Desktop.
Sqitch create enum templates for pg engine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Deploy [% project %]:[% change %] to [% engine %] | |
| [% FOREACH item IN requires -%] | |
| -- requires: [% item %] | |
| [% END -%] | |
| [% FOREACH item IN conflicts -%] | |
| -- conflicts: [% item %] | |
| [% END -%] | |
| BEGIN; | |
| SET SEARCH_PATH TO [% IF schema %][% schema %],[% END %]public; | |
| CREATE TYPE [% IF name %][% name %][% ELSE %][% change %][% END %] AS ENUM ( | |
| [% FOREACH val IN value -%] | |
| '[% val %]'[% loop.last ? '' : ',' %] | |
| [% END -%] | |
| ); | |
| COMMIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Revert [% project %]:[% change %] from [% engine %] | |
| BEGIN; | |
| SET SEARCH_PATH TO [% IF schema %][% schema %],[% END %]public; | |
| DROP TYPE [% IF name %][% name %][% ELSE %][% change %][% END %] CASCADE; | |
| COMMIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Verify [% project %]:[% change %] on [% engine %] | |
| BEGIN; | |
| SELECT true | |
| FROM pg_type t | |
| JOIN pg_namespace n ON t.typnamespace = n.oid | |
| WHERE typname = '[% IF name %][% name %][% ELSE %][% change %][% END %]' | |
| [% IF schema %]AND n.nspname = '[% schema %]'[% END %]; | |
| ROLLBACK; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment