Skip to content
This repository has been archived by the owner on Sep 10, 2020. It is now read-only.

Commit

Permalink
Add readme for how to set up test database
Browse files Browse the repository at this point in the history
  • Loading branch information
redshiftzero committed Sep 9, 2016
1 parent ac99a8c commit 93648b3
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions fpsd/test_db_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Test Database Setup

## Setup tablefunc

The `postgresql-contrib` package will need to be added as we make use of an extension to postgresql `tablefunc` in some of the queries (`crosstab()` requires the `tablefunc` extension):

```
sudo apt-get install postgresql-contrib
```

In order to use the crosstab() function, the additional module `tablefunc` must be installed once per database. From psql:

```
fpsd=> CREATE EXTENSION tablefunc;
testfpsd=> CREATE EXTENSION tablefunc;
```

## Create new database

As postgres user:

```
fpsd=> CREATE DATABASE testfpsd WITH OWNER fp_user;
```

We now want to create the tables, and drop some of the foriegn key constraints so that we don't have to fill a ton of tables when we run tests. As fp_user:

```
testfpsd=> \i create_schema_raw.sql
CREATE SCHEMA
testfpsd=> \i create_table_hs_history.sql
CREATE TABLE
testfpsd=> \i create_table_crawls.sql
CREATE TABLE
testfpsd=> \i create_table_frontpage_examples.sql
CREATE TABLE
testfpsd=> \i create_table_frontpage_traces.sql
CREATE TABLE
testfpsd=> \i create_schema_features.sql
psql:create_schema_features.sql:1: NOTICE: schema "features" does not exist, skipping
DROP SCHEMA
CREATE SCHEMA
testfpsd=> ALTER TABLE raw.frontpage_traces DROP CONSTRAINT frontpage_traces_exampleid_fkey;
ALTER TABLE
testfpsd=> ALTER TABLE raw.frontpage_examples DROP CONSTRAINT frontpage_examples_hsid_fkey;
ALTER TABLE
testfpsd=> ALTER TABLE raw.frontpage_examples DROP CONSTRAINT frontpage_examples_crawlid_fkey;
ALTER TABLE
```

0 comments on commit 93648b3

Please sign in to comment.