Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DB Schema #8

Merged
merged 56 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a8fe808
add sequelize
kratsg Oct 24, 2017
2f60e98
add mysql backend
kratsg Oct 24, 2017
b04ac48
add authenticate method for testing the connection
kratsg Oct 25, 2017
5a73763
create services/ folder. move logger and db to services
kratsg Oct 25, 2017
695427a
add sequelize-cli
kratsg Oct 25, 2017
60f69d9
const, not var
kratsg Oct 25, 2017
31fd227
add initial setup from cli
kratsg Oct 25, 2017
2bc5d09
update to point to models correctly
kratsg Oct 25, 2017
43965e7
add configs for sequelize
kratsg Oct 25, 2017
d53fb5d
remove db.js - use sequelize layout
kratsg Oct 25, 2017
0a504ab
let's test that we can connect/authenticate
kratsg Oct 25, 2017
5d33487
comment out authentication for right now
kratsg Oct 25, 2017
28fad80
update README
kratsg Oct 25, 2017
4a5bcc2
add sequelizerc file
kratsg Oct 25, 2017
b1b69d4
use a .js for configuration instead
kratsg Oct 25, 2017
996ad08
update config to js format
kratsg Oct 25, 2017
5161b54
add more documentation in README
kratsg Oct 25, 2017
971f978
add User model
kratsg Oct 25, 2017
dfe19ac
add Category model
kratsg Oct 25, 2017
a78e196
Add introspect and terminology models
kratsg Oct 25, 2017
a3687c6
add Sign model
kratsg Oct 25, 2017
8308b1e
update table names
kratsg Nov 21, 2017
1f92343
author updated
kratsg Nov 21, 2017
91507ba
minor typo in author.js
kratsg Nov 21, 2017
144ebbd
sign updated
kratsg Nov 21, 2017
2e5f037
update region
kratsg Nov 21, 2017
12b13f2
add note about inserting new region
kratsg Nov 21, 2017
ef56990
update source
kratsg Nov 21, 2017
a7e01e9
update category
kratsg Nov 21, 2017
0c92dc8
make sure through-tables are named the same
kratsg Nov 21, 2017
dd351a3
update gloss
kratsg Nov 21, 2017
407cc59
update region relationship
kratsg Nov 21, 2017
1dc448e
fix up models to use associations correctly
kratsg Nov 21, 2017
82d57b9
add insructions for db dev in README
kratsg Nov 21, 2017
03684e7
fix up typo in category_sign
kratsg Nov 21, 2017
dd2905c
ignore DS_Store for mac
kratsg Nov 22, 2017
2ac8347
add migration to create author table
kratsg Nov 22, 2017
9003200
migration to create category table
kratsg Nov 22, 2017
de17032
add gloss migration
kratsg Nov 22, 2017
bf1fe32
add region migration
kratsg Nov 22, 2017
fb126a2
add sign migration
kratsg Nov 22, 2017
7718b50
add source migration
kratsg Nov 22, 2017
a8b154d
add author relationship to signs
kratsg Nov 22, 2017
c45f98b
add region relationship to authors
kratsg Nov 22, 2017
876ffe9
add gloss_gloss relationship
kratsg Nov 22, 2017
189ac71
add gloss-source relationship
kratsg Nov 22, 2017
1cc4b87
add region-sign relationship
kratsg Nov 22, 2017
5e74acf
add category-source relationship
kratsg Nov 22, 2017
7df5770
add category-sign relationship
kratsg Nov 22, 2017
c828efd
add gloss-sign relationship
kratsg Nov 22, 2017
a95c595
add example of migration procedure for belongsToMany
kratsg Nov 22, 2017
c83fad3
typo in README for code block
kratsg Nov 22, 2017
b175d4e
code block typo
kratsg Nov 22, 2017
f736ee9
add references for more info
kratsg Nov 22, 2017
9ce6d9d
sequelize-cli as a live dependency for running migrations
kratsg Nov 23, 2017
90e1542
a composite primary key is already unique, no need to add an extra un…
kratsg Nov 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add initial setup from cli
  • Loading branch information
kratsg committed Nov 27, 2017
commit 31fd2271a64b117b806b2cc46c1218fba06c5e94
20 changes: 20 additions & 0 deletions config/database.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"development": {
"username": "root",
"password": null,
"database": "database_development",
"host": "127.0.0.1",
"dialect": "mysql"
},
"test": {
"username": "root",
"password": null,
"database": "database_test",
"host": "127.0.0.1",
"dialect": "mysql"
},
"production": {
"use_env_variable": "CLEARDB_DATABASE_URL",
"dialect": "mysql"
}
}
Empty file added db/migrations/.gitkeep
Empty file.
36 changes: 36 additions & 0 deletions db/models/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var fs = require('fs');
var path = require('path');
var Sequelize = require('sequelize');
var basename = path.basename(__filename);
var env = process.env.NODE_ENV || 'development';
var config = require(__dirname + '/../../config/database.json')[env];
var db = {};

if (config.use_env_variable) {
var sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
var sequelize = new Sequelize(config.database, config.username, config.password, config);
}

fs
.readdirSync(__dirname)
.filter(file => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.forEach(file => {
var model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model;
});

Object.keys(db).forEach(modelName => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;
Empty file added db/seeders/.gitkeep
Empty file.