Skip to content

Commit 51ca2e5

Browse files
author
joeltaylor
committed
Add initial migration
1 parent 277c7f9 commit 51ca2e5

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
exports.up = function(pgm) {
2+
pgm.createTable('users', {
3+
id: 'id',
4+
admin: { type: 'boolean', notNull: true, default: false },
5+
github_id: { type: 'integer', notNull: true },
6+
name: { type: 'text', notNull: true },
7+
email: { type: 'text' },
8+
avatar_url: { type: 'text', notNull: true },
9+
created_at: { type: 'timestamp', default: pgm.func('statement_timestamp()') }
10+
});
11+
12+
pgm.createTable('articles', {
13+
id: 'id',
14+
approved: { type: 'boolean' },
15+
slug: { type: 'text', notNull: true },
16+
title: { type: 'text', notNull: true },
17+
body: { type: 'text' },
18+
url: { type: 'text' },
19+
news: { type: 'boolean', notNull: true, default: false },
20+
user_id: { type: 'integer' },
21+
published_at: { type: 'timestamp' },
22+
created_at: { type: 'timestamp', default: pgm.func('statement_timestamp()') }
23+
});
24+
25+
pgm.createTable('comments', {
26+
id: 'id',
27+
approved: { type: 'boolean', notNull: true, default: false },
28+
user_id: { type: 'integer', references: 'users', notNull: true },
29+
article_id: { type: 'integer', references: 'articles', notNull: true },
30+
body: { type: 'text' },
31+
flagged: { type: 'boolean', notNutll: true, default: true },
32+
created_at: { type: 'timestamp', default: pgm.func('statement_timestamp()') }
33+
});
34+
};
35+
36+
exports.down = function(pgm) {
37+
38+
};

setup.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ then
66
echo "javascriptcom database already loaded"
77
else
88
createdb javascriptcom
9-
psql javascriptcom < db/schema.sql
109
fi
1110

1211
echo "installing bower assets"

0 commit comments

Comments
 (0)