Skip to content

Instantly share code, notes, and snippets.

@shunjikonishi
Created April 24, 2015 04:21
Show Gist options
  • Save shunjikonishi/2db1bde3286b1bc548f2 to your computer and use it in GitHub Desktop.
Save shunjikonishi/2db1bde3286b1bc548f2 to your computer and use it in GitHub Desktop.
node-sql-fixtures #28
"use strict";
/*
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NULL,
github_username VARCHAR(255) NULL,
password VARCHAR(255) NULL,
image_url VARCHAR(255) NULL,
delete_flg BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
*/
var
config = {
"client": "pg",
"connection": {
"host": "192.168.33.20",
"user": "vagrant",
"password": "vagrant",
"database": "test",
"port": 5432
}
},
data = {
"users": {
"name": "user1",
"email": "user1@test.com",
"password": "hoge"
}
},
fixtures = new (require("sql-fixtures"))(config);
function initData(done) {
fixtures.knex("users").del().then(function() {
fixtures.create(data, function() {
done();
});
});
}
initData(function() {
console.log("finish!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment