Skip to content

Commit

Permalink
create script migrate and tables on database
Browse files Browse the repository at this point in the history
  • Loading branch information
brielsilva committed Feb 23, 2022
1 parent 33e2742 commit b323130
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules
db/migrate
node_modules
15 changes: 15 additions & 0 deletions db/migrate/migration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const db = require('../db');

db.query('DROP TABLE contacts;');
db.query(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`)
db.query(`CREATE TABLE IF NOT EXISTS contacts(
id UUID NOT NULL UNIQUE DEFAULT uuid_generate_v4(),
email VARCHAR NOT NULL UNIQUE,
name VARCHAR NOT NULL,
phone VARCHAR NOT NULL,
gender VARCHAR NOT NULL,
birthday DATE NOT NULL,
picture VARCHAR NOT NULL
);`);


1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("Hello")
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"eslint-plugin-import": "^2.25.4"
},
"scripts": {
"start": "node test.js"
"migrate": "node db/migrate/migration.js",
"start": "node index.js"
},
"dependencies": {
"dotenv": "^16.0.0",
Expand Down

0 comments on commit b323130

Please sign in to comment.