|
| 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 | +}; |
0 commit comments