Skip to content

Commit

Permalink
Merge pull request #243 from n8io/feature/seed-admin-user
Browse files Browse the repository at this point in the history
feat(db): 🌱 Add `admin` seed user to db
  • Loading branch information
n8io authored Nov 21, 2020
2 parents d1d6aee + 6b3f22d commit a958e20
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/service/src/migrations/20201120210332_seed-admin-user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { toTableName } from 'db/migrate/utils';
import { Db } from 'types/db';

const tableName = Db.Table.USERS;

const fullyQualifiedTableName = toTableName(tableName);
const adminId = 'ckhr1ebnk0003i1z89g0fe6mm';

const up = (knex) =>
knex.raw(`
INSERT INTO ${fullyQualifiedTableName} (id, username, role, given_name, family_name, name, email, password_hash)
VALUES ('${adminId}', 'admin', 'ADMIN', 'Nate', 'Clark', 'clark,nate', '[email protected]', '');
`);

const down = (knex) =>
knex.raw(`
DELETE FROM ${fullyQualifiedTableName} WHERE id = '${adminId}';
`);

export { down, up };

0 comments on commit a958e20

Please sign in to comment.