Commit 9ea9e5d1 authored by Mark Stenglein's avatar Mark Stenglein

Fix models to properly support relationships

- Forgot to add some things:
    - _read_: just had no idea what I was doing before
- In the future when this breaks: I blame http://stackoverflow.com/a/23035179
parent 42cbe59a
Pipeline #685 failed with stage
in 43 seconds
......@@ -3,7 +3,16 @@ module.exports = function (sequelize, DataTypes) {
// unique index/key
crn: {
type: DataTypes.STRING,
unique: true
unique: true,
primaryKey: true
},
semester: {
type: DataTypes.STRING,
references: {
model: 'Semester',
key : 'slug'
}
},
name: DataTypes.STRING,
......
......@@ -2,7 +2,16 @@ module.exports = function (sequelize, DataTypes) {
var Semester = sequelize.define('Semester', {
slug: {
type: DataTypes.STRING,
unique: true
unique: true,
primaryKey: true
},
university: {
type: DataTypes.STRING,
references: {
model: 'University',
key : 'slug'
}
},
name: DataTypes.STRING
......
......@@ -3,7 +3,8 @@ module.exports = function (sequelize, DataTypes) {
slug: {
type: DataTypes.STRING,
allowNull: false,
unique: true
unique: true,
primaryKey: true
},
name: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment