From b0429987356459c270dbf43ce7976873c2145f16 Mon Sep 17 00:00:00 2001 From: Konstantin Tarkus Date: Tue, 26 Feb 2019 15:05:35 +0300 Subject: [PATCH] Remove db-save script (#324) --- knexfile.js | 11 ----------- scripts/db-save.js | 39 --------------------------------------- 2 files changed, 50 deletions(-) delete mode 100644 scripts/db-save.js diff --git a/knexfile.js b/knexfile.js index b803f22a..974b5701 100644 --- a/knexfile.js +++ b/knexfile.js @@ -28,15 +28,4 @@ module.exports = { ca: fs.readFileSync(process.env.PGSSLROOTCERT, 'utf8'), }, }, - // The order in which data is being saved or restored - // when you run `yarn db-save` or `yarn db-seed`. - tables: [ - 'users', - 'user_identities', - 'user_tokens', - 'stories', - 'story_points', - 'comments', - 'comment_points', - ], }; diff --git a/scripts/db-save.js b/scripts/db-save.js deleted file mode 100644 index 2e25f150..00000000 --- a/scripts/db-save.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * React Starter Kit for Firebase - * https://github.com/kriasoft/react-firebase-starter - * Copyright (c) 2015-present Kriasoft | MIT License - */ - -const fs = require('fs'); -const path = require('path'); -const knex = require('knex'); -const prettier = require('prettier'); -const config = require('../knexfile'); - -const db = knex(config); - -(async () => { - for (const table of config.tables) { - let rows; - - try { - rows = await db - .table(table) - .orderBy('created_at') - .select(); - } catch (err) { - if (err.routine === 'errorMissingColumn') { - rows = await db.table(table).select(); - } else { - throw err; - } - } - - fs.writeFileSync( - path.join(__dirname, `../seeds/${table}.json`), - prettier.format(JSON.stringify(rows), { parser: 'json' }), - 'utf8', - ); - } - db.destroy(); -})().catch(console.error);