Skip to content

Commit

Permalink
issue #22: fixes for deployment to Heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
rngadam committed May 4, 2018
1 parent 1cb3db6 commit a9abc59
Show file tree
Hide file tree
Showing 11 changed files with 330 additions and 300 deletions.
22 changes: 15 additions & 7 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,34 @@ Because Heroku requires the app to be in the root, we use subtree to push:
git subtree push --prefix server heroku master
```

Updating schema:

```bash
psql -v "ON_ERROR_STOP=1" -b -1 -e -f sql/PSQL.sql `heroku pg:credentials:url | tail -1`
```

Restarting the dyno (to load changes to the database for example)

```bash
heroku restart -a coderbunker-timesheet
```

## data transfer to/from heroku

Pushing the local database:

```bash
heroku pg:push timesheet postgresql-rigid-65921 --app coderbunker-timesheet
```

Puling the Heroku database locally and making a copy before changing the pulled version
Pulling the Heroku database locally and making a copy before changing the pulled version
(adjust date):

```bash
heroku pg:pull postgresql-rigid-65921 heroku-timesheet --app coderbunker-timesheet
psql -c 'CREATE DATABASE "heroku-timesheet-20180416" TEMPLATE "heroku-timesheet";' postgres
```


Restarting the dyno (to load changes to the database for example)

```bash
heroku restart -a coderbunker-timesheet
```
## Manage Domain

### CNAME Setup for Heroku app
Expand Down
2 changes: 2 additions & 0 deletions server/sql/003-psql-create-extensions-localhost.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE EXTENSION IF NOT EXISTS pgtap;
CREATE EXTENSION IF NOT EXISTS postgres_fdw;
4 changes: 2 additions & 2 deletions server/sql/005-psql-create-extensions.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS postgres_fdw;
-- CREATE EXTENSION IF NOT EXISTS postgres_fdw;
CREATE EXTENSION IF NOT EXISTS unaccent;
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE EXTENSION IF NOT EXISTS citext;

CREATE EXTENSION IF NOT EXISTS citext;
CREATE EXTENSION IF NOT EXISTS pgtap;
-- CREATE EXTENSION IF NOT EXISTS pgtap;
2 changes: 1 addition & 1 deletion server/sql/050-psql-create-postgraphql.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

-- postgraphql interface
\ir postgraphql.sql
\ir postgraphql/postgraphql.sql
2 changes: 1 addition & 1 deletion server/sql/PSQL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
\ir 030-psql-incoming-to-model.sql
\ir 040-psql-create-reports.sql
\ir 050-psql-create-postgraphql.sql
\ir 900-psql-testsuite.sql
-- \ir 900-psql-testsuite.sql
21 changes: 15 additions & 6 deletions server/sql/incoming/people.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@ CREATE OR REPLACE VIEW incoming.people_project AS
FROM incoming.raw_people
;

DROP MATERIALIZED VIEW IF EXISTS incoming.nickname_to_email CASCADE;
CREATE MATERIALIZED VIEW incoming.nickname_to_email AS
SELECT resource, email
FROM incoming.people_project
WHERE resource IS NOT NULL
GROUP BY resource, email;
DO $$
BEGIN
PERFORM * FROM pg_catalog.pg_matviews WHERE matviewname = 'nickname_to_email' AND schemaname = 'incoming';
IF NOT FOUND THEN
CREATE MATERIALIZED VIEW incoming.nickname_to_email AS
SELECT resource, email
FROM incoming.people_project
WHERE resource IS NOT NULL
GROUP BY resource, email;
CREATE UNIQUE INDEX nickname_to_email_index ON incoming.nickname_to_email(resource, email);
ELSE
REFRESH MATERIALIZED VIEW CONCURRENTLY incoming.nickname_to_email;
END IF;
END;
$$ LANGUAGE PLPGSQL;

CREATE OR REPLACE VIEW incoming.people AS
SELECT
Expand Down
Loading

0 comments on commit a9abc59

Please sign in to comment.