Clone into ~/.sqitch/templates
:
git clone https://github.com/explodinglabs/sqitch-templates ~/.sqitch/templates
Add an ad-hoc change:
sqitch add [change] --note 'What it does'
Create schema:
create-schema [schema]
Drop schema (does not cascade, so drop everything in the schema first):
drop-schema [schema]
Create table (edit the table):
create-table [schema] [table]
Drop table:
drop-table [schema] [table]
Add column:
add-column [schema] [table] [column]
Rename column:
Drop column:
drop-column [schema] [table] [column]
Create role:
create-role [role] nologin
Grant schema usage:
grant-usage [schema] [role]
./sqitch add grant_api_usage_to_anon --template grant_schema_usage --set schema=api --set role=anon --note 'Grant usage on api schema to anon'
Grant select:
grant-select [schema] [table] [role]
./sqitch add grant_select_api_teams --template grant_view_privileges --set type=select --set schema=api --set table=teams --set role=web_user --note 'Grant select on api.teams to web_user'
Grant function execute (edit the function params):
./sqitch add grant_execute_api_foo --template grant_execute --set name=api.login --set role=web_user --note 'Grant execute on api.login to web_user'
Grant role membership (i.e. grant [role] to [role]
.):
grant [role] [role]
./sqitch add grant_role_membership_foo --template grant_role_membership --set from_role=web_user --set role=authenticator --note 'Grant web_user to authenticator'
Create function:
create-function data playlist_updated
Drop function (edit the revert script to add the function back):
To edit a function, just edit the "create function" deploy script and sqitch rebase, or if the project has been deployed to another environment, do a sqitch rework.
Create trigger:
create-trigger [schema] [table] [trigger] [function]
Drop trigger:
create-extension [extension]
Create view (Then edit the select statement):
./sqitch add create_view_api_teams --template create_view --set schema=api --set name=teams --note 'Add api.teams view'