Last active
October 9, 2016 13:52
-
-
Save deinspanjer/67a6d19d8fe9a1f903ea6587af6f8ae0 to your computer and use it in GitHub Desktop.
Sqitch create view 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 OR REPLACE VIEW [% IF name %][% name %][% ELSE %][% change %][% END %] AS ( | |
| SELECT * FROM [% IF source; source %][% ELSE %]XXX SOURCE[% END %] | |
| ); | |
| --GRANT SELECT ON TABLE [% IF name %][% name %][% ELSE %][% change %][% END %] TO PUBLIC; | |
| 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 VIEW [% IF name %][% name %][% ELSE %][% change %][% END %] RESTRICT; | |
| 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 '[% IF schema; schema %].[% END %][% IF name %][% name %][% ELSE %][% change %][% END %]'::REGCLASS; | |
| ROLLBACK; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment