From 1511ae756c97077c0ade4b3b6b48097ff214b947 Mon Sep 17 00:00:00 2001
From: ManifoldFR <wilson.jallet@gmail.com>
Date: Fri, 2 Mar 2018 14:51:31 +0100
Subject: [PATCH] Added posts table to db

---
 README.md                                    |  2 +-
 db/migrations/20180302130024_create_posts.js | 15 +++++++++++++++
 db/seeds/01_create_groups.js                 |  6 ------
 db/seeds/02_make_posts.js                    | 18 ++++++++++++++++++
 4 files changed, 34 insertions(+), 7 deletions(-)
 create mode 100644 db/migrations/20180302130024_create_posts.js
 create mode 100644 db/seeds/02_make_posts.js

diff --git a/README.md b/README.md
index 005b55d..a0c3b75 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 [![pipeline status](https://gitlab.binets.fr/br/sigma-backend/badges/master/pipeline.svg)](https://gitlab.binets.fr/br/sigma-backend/commits/master)
 
-## Introduction
+# Introduction
 
 Ce dépôt contient le _backend_ de Sigma, le successeur de Frankiz, un site étudiant permettant de gérer les groupes et les étudiants du plateau de Saclay.
 
diff --git a/db/migrations/20180302130024_create_posts.js b/db/migrations/20180302130024_create_posts.js
new file mode 100644
index 0000000..b5d952a
--- /dev/null
+++ b/db/migrations/20180302130024_create_posts.js
@@ -0,0 +1,15 @@
+
+exports.up = function(knex, Promise) {
+    return knex.schema.createTable('posts', function (table) {
+        table.timestamps(true,true);
+        table.increments('id');
+
+        table.string('title').notNullable();
+        table.text('description');
+        table.specificType('authors', knex.raw('varchar(128)[]')).notNullable();
+    });
+};
+
+exports.down = function(knex, Promise) {
+    return knex.schema.dropTable('posts');
+};
diff --git a/db/seeds/01_create_groups.js b/db/seeds/01_create_groups.js
index 70464aa..1eb8237 100644
--- a/db/seeds/01_create_groups.js
+++ b/db/seeds/01_create_groups.js
@@ -17,12 +17,6 @@ exports.seed = function(knex, Promise) {
           website: 'binet-jtx.com',
           school: 'polytechnique',
           parentuid: 'kes'
-        },{
-          name: 'Faerix',
-          uid: 'faerix',
-          website: 'faerix.net',
-          school: 'polytechnique',
-          parentuid: 'kes'
         },{
           name: 'Kès',
           uid: 'kes',
diff --git a/db/seeds/02_make_posts.js b/db/seeds/02_make_posts.js
new file mode 100644
index 0000000..4b9f577
--- /dev/null
+++ b/db/seeds/02_make_posts.js
@@ -0,0 +1,18 @@
+
+exports.seed = function(knex, Promise) {
+  // Deletes ALL existing entries
+  return knex('posts').del()
+    .then(function () {
+      const posts = [{
+        title: "Fissurer c'est bien",
+        description: "Les nouveaux ordis du JTX sont arrivés ! Le BR aide à les installer ;)",
+        authors: ['br','jtx']
+      },{
+        title: "Proj'et Promotion",
+        description: "La nouvelle proj' du JTX arrive !",
+        authors: ['br']
+      }];
+
+      return knex('posts').insert(posts);
+    });
+};
-- 
GitLab