Skip to content

Commit

Permalink
adds content tables to db
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmullen committed Jan 30, 2019
1 parent 5016f74 commit ac3b684
Show file tree
Hide file tree
Showing 39 changed files with 570 additions and 119 deletions.
1 change: 1 addition & 0 deletions packages/cms/db/author_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/author_content");
1 change: 1 addition & 0 deletions packages/cms/db/profile_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/profile_content");
1 change: 1 addition & 0 deletions packages/cms/db/story_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/story_content");
1 change: 1 addition & 0 deletions packages/cms/db/story_description_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/story_description_content");
1 change: 1 addition & 0 deletions packages/cms/db/story_footnote_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/story_footnote_content");
1 change: 1 addition & 0 deletions packages/cms/db/storytopic_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/storytopic_content");
1 change: 1 addition & 0 deletions packages/cms/db/storytopic_description_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/storytopic_description_content");
1 change: 1 addition & 0 deletions packages/cms/db/storytopic_stat_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/storytopic_stat_content");
1 change: 1 addition & 0 deletions packages/cms/db/storytopic_subtitle_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/storytopic_subtitle_content");
1 change: 1 addition & 0 deletions packages/cms/db/topic_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/topic_content");
1 change: 1 addition & 0 deletions packages/cms/db/topic_description_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/topic_description_content");
1 change: 1 addition & 0 deletions packages/cms/db/topic_stat_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/topic_stat_content");
1 change: 1 addition & 0 deletions packages/cms/db/topic_subtitle_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../src/db/topic_subtitle_content");
26 changes: 5 additions & 21 deletions packages/cms/src/db/author.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ module.exports = function(sequelize, db) {
primaryKey: true,
autoIncrement: true
},
name: {
type: db.STRING,
defaultValue: "New Author"
},
title: {
type: db.STRING,
defaultValue: "New Title"
},
image: {
type: db.STRING,
defaultValue: "New Image"
},
twitter: {
type: db.STRING,
defaultValue: "New Twitter"
},
story_id: {
type: db.INTEGER,
onDelete: "cascade",
Expand All @@ -31,18 +15,18 @@ module.exports = function(sequelize, db) {
key: "id"
}
},
ordering: db.INTEGER,
bio: {
type: db.TEXT,
defaultValue: "New Bio"
}
ordering: db.INTEGER
},
{
freezeTableName: true,
timestamps: false
}
);

a.associate = models => {
a.hasMany(models.author_content, {foreignKey: "parent_id", sourceKey: "id", as: "content"});
};

return a;

};
50 changes: 50 additions & 0 deletions packages/cms/src/db/author_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = function(sequelize, db) {

const a = sequelize.define("author_content",
{
id: {
type: db.INTEGER,
primaryKey: true
},
lang: {
type: db.STRING,
primaryKey: true
},
name: {
type: db.STRING,
defaultValue: "New Author"
},
title: {
type: db.STRING,
defaultValue: "New Title"
},
image: {
type: db.STRING,
defaultValue: "New Image"
},
twitter: {
type: db.STRING,
defaultValue: "New Twitter"
},
parent_id: {
type: db.INTEGER,
onDelete: "cascade",
references: {
model: "author",
key: "id"
}
},
bio: {
type: db.TEXT,
defaultValue: "New Bio"
}
},
{
freezeTableName: true,
timestamps: false
}
);

return a;

};
15 changes: 2 additions & 13 deletions packages/cms/src/db/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,12 @@ module.exports = function(sequelize, db) {
primaryKey: true,
autoIncrement: true
},
title: {
type: db.STRING,
defaultValue: "New Profile"
},
subtitle: {
type: db.TEXT,
defaultValue: "New Subtitle"
},
slug: {
type: db.STRING,
defaultValue: "new-profile-slug"
},
ordering: db.INTEGER,
dimension: db.STRING,
label: {
type: db.STRING,
defaultValue: "New Profile Label"
}
dimension: db.STRING
},
{
freezeTableName: true,
Expand All @@ -33,6 +21,7 @@ module.exports = function(sequelize, db) {
);

p.associate = models => {
p.hasMany(models.profile_content, {foreignKey: "parent_id", sourceKey: "id", as: "content"});
p.hasMany(models.topic, {foreignKey: "profile_id", sourceKey: "id", as: "topics"});
p.hasMany(models.generator, {foreignKey: "profile_id", sourceKey: "id", as: "generators"});
p.hasMany(models.materializer, {foreignKey: "profile_id", sourceKey: "id", as: "materializers"});
Expand Down
42 changes: 42 additions & 0 deletions packages/cms/src/db/profile_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = function(sequelize, db) {

const p = sequelize.define("profile_content",
{
id: {
type: db.INTEGER,
primaryKey: true
},
lang: {
type: db.STRING,
primaryKey: true
},
title: {
type: db.STRING,
defaultValue: "New Profile"
},
subtitle: {
type: db.TEXT,
defaultValue: "New Subtitle"
},
label: {
type: db.STRING,
defaultValue: "New Profile Label"
},
parent_id: {
type: db.INTEGER,
onDelete: "cascade",
references: {
model: "profile",
key: "id"
}
}
},
{
freezeTableName: true,
timestamps: false
}
);

return p;

};
14 changes: 1 addition & 13 deletions packages/cms/src/db/story.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ module.exports = function(sequelize, db) {
primaryKey: true,
autoIncrement: true
},
title: {
type: db.STRING,
defaultValue: "New Story"
},
subtitle: {
type: db.TEXT,
defaultValue: "New Subtitle"
},
image: {
type: db.STRING,
defaultValue: "New Image"
},
ordering: db.INTEGER,
slug: {
type: db.STRING,
Expand All @@ -36,7 +24,7 @@ module.exports = function(sequelize, db) {
);

s.associate = models => {
// s.belongsToMany(models.authors, {through: "stories_authors", foreignKey: "story_id", otherKey: "author_id", as: "authors"});
s.hasMany(models.story_content, {foreignKey: "parent_id", sourceKey: "id", as: "content"});
s.hasMany(models.author, {foreignKey: "story_id", sourceKey: "id", as: "authors"});
s.hasMany(models.story_footnote, {foreignKey: "story_id", sourceKey: "id", as: "footnotes"});
s.hasMany(models.story_description, {foreignKey: "story_id", sourceKey: "id", as: "descriptions"});
Expand Down
51 changes: 51 additions & 0 deletions packages/cms/src/db/story_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module.exports = function(sequelize, db) {

const s = sequelize.define("story_content",
{
id: {
type: db.INTEGER,
primaryKey: true
},
lang: {
type: db.STRING,
primaryKey: true
},
title: {
type: db.STRING,
defaultValue: "New Story"
},
subtitle: {
type: db.TEXT,
defaultValue: "New Subtitle"
},
image: {
type: db.STRING,
defaultValue: "New Image"
},
ordering: db.INTEGER,
slug: {
type: db.STRING,
defaultValue: "new-story-slug"
},
date: {
type: db.DATE,
defaultValue: "2018-01-01 00:00:00"
},
parent_id: {
type: db.INTEGER,
onDelete: "cascade",
references: {
model: "story",
key: "id"
}
}
},
{
freezeTableName: true,
timestamps: false
}
);

return s;

};
10 changes: 5 additions & 5 deletions packages/cms/src/db/story_description.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ module.exports = function(sequelize, db) {
type: db.INTEGER,
primaryKey: true,
autoIncrement: true
},
description: {
type: db.TEXT,
defaultValue: "New Description"
},
},
story_id: {
type: db.INTEGER,
onDelete: "cascade",
Expand All @@ -27,6 +23,10 @@ module.exports = function(sequelize, db) {
}
);

s.associate = models => {
s.hasMany(models.story_description_content, {foreignKey: "parent_id", sourceKey: "id", as: "content"});
};

return s;

};
34 changes: 34 additions & 0 deletions packages/cms/src/db/story_description_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = function(sequelize, db) {

const s = sequelize.define("story_description_content",
{
id: {
type: db.INTEGER,
primaryKey: true
},
lang: {
type: db.STRING,
primaryKey: true
},
description: {
type: db.TEXT,
defaultValue: "New Description"
},
parent_id: {
type: db.INTEGER,
onDelete: "cascade",
references: {
model: "story_description",
key: "id"
}
}
},
{
freezeTableName: true,
timestamps: false
}
);

return s;

};
12 changes: 4 additions & 8 deletions packages/cms/src/db/story_footnote.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ module.exports = function(sequelize, db) {
primaryKey: true,
autoIncrement: true
},
title: {
type: db.STRING,
defaultValue: "New Title"
},
description: {
type: db.TEXT,
defaultValue: "New Footnote"
},
story_id: {
type: db.INTEGER,
onDelete: "cascade",
Expand All @@ -31,6 +23,10 @@ module.exports = function(sequelize, db) {
}
);

s.associate = models => {
s.hasMany(models.story_footnote_content, {foreignKey: "parent_id", sourceKey: "id", as: "content"});
};

return s;

};
Loading

0 comments on commit ac3b684

Please sign in to comment.