-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Integrate author haven with Postgresql - Populate database with necessary tables [Delivers #163478786]
- Loading branch information
Peace Oyedeji
authored and
Peace Oyedeji
committed
Feb 5, 2019
1 parent
01e42d4
commit 440879e
Showing
23 changed files
with
1,006 additions
and
56 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,61 @@ | ||
'use strict'; | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
return queryInterface.createTable('users', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
username: { | ||
type: Sequelize.STRING | ||
}, | ||
email: { | ||
type: Sequelize.STRING | ||
}, | ||
password: { | ||
type: Sequelize.STRING | ||
}, | ||
bio: { | ||
type: Sequelize.TEXT | ||
}, | ||
imageUrl: { | ||
type: Sequelize.STRING | ||
}, | ||
isVerified: { | ||
type: Sequelize.BOOLEAN | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}); | ||
up(queryInterface, Sequelize) { | ||
return queryInterface.sequelize.query('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";') | ||
.then(() => queryInterface.createTable('User', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()') | ||
}, | ||
username: { | ||
allowNull: { | ||
args: false, | ||
msg: 'Please enter a username' | ||
}, | ||
type: Sequelize.STRING, | ||
unique: { | ||
args: true, | ||
msg: 'Username already exist' | ||
}, | ||
}, | ||
email: { | ||
allowNull: false, | ||
type: Sequelize.STRING, | ||
unique: true, | ||
validate: { | ||
isEmail: true | ||
} | ||
}, | ||
password: { | ||
allowNull: { | ||
args: false, | ||
msg: 'Please enter a password' | ||
}, | ||
type: Sequelize.STRING, | ||
validate: { | ||
len: [8, 72] | ||
}, | ||
}, | ||
bio: { | ||
type: Sequelize.TEXT | ||
}, | ||
imageUrl: { | ||
type: Sequelize.STRING | ||
}, | ||
isVerified: { | ||
allowNull: false, | ||
type: Sequelize.BOOLEAN | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
})); | ||
}, | ||
down: (queryInterface, Sequelize) => { | ||
return queryInterface.dropTable('users'); | ||
} | ||
}; | ||
down: queryInterface => queryInterface.dropTable('User'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('UserFollower', { | ||
userId: { | ||
allowNull: false, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()'), | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'User', | ||
key: 'id', | ||
as: 'userId', | ||
}, | ||
}, | ||
followerId: { | ||
allowNull: false, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()'), | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'User', | ||
key: 'id', | ||
as: 'followerId', | ||
} | ||
} | ||
}), | ||
down: queryInterface => queryInterface.dropTable('UserFollower'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('Category', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
categoryName: { | ||
allowNull: false, | ||
type: Sequelize.TEXT | ||
}, | ||
}), | ||
down: queryInterface => queryInterface.dropTable('Category') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('Article', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()') | ||
}, | ||
slug: { | ||
allowNull: { | ||
args: false, | ||
msg: 'Please enter a title' | ||
}, | ||
type: Sequelize.TEXT | ||
}, | ||
body: { | ||
allowNull: { | ||
args: false, | ||
msg: 'Please enter your text' | ||
}, | ||
type: Sequelize.TEXT | ||
}, | ||
description: { | ||
allowNull: { | ||
args: false, | ||
msg: 'Please give description' | ||
}, | ||
type: Sequelize.TEXT | ||
}, | ||
authorId: { | ||
allowNull: false, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()'), | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'User', | ||
key: 'id', | ||
as: 'authorId', | ||
}, | ||
}, | ||
references: { | ||
type: Sequelize.ARRAY(Sequelize.STRING) | ||
}, | ||
categoryId: { | ||
allowNull: false, | ||
type: Sequelize.INTEGER, | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'Category', | ||
key: 'id', | ||
as: 'categoryId', | ||
}, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}), | ||
down: queryInterface => queryInterface.dropTable('Article') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('Notification', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()') | ||
}, | ||
userId: { | ||
allowNull: false, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()'), | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'User', | ||
key: 'id', | ||
as: 'userId', | ||
}, | ||
}, | ||
notificationBody: { | ||
allowNull: { | ||
args: false, | ||
msg: 'What is the notification about?' | ||
}, | ||
type: Sequelize.TEXT | ||
}, | ||
seen: { | ||
allowNull: false, | ||
type: Sequelize.BOOLEAN | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}), | ||
down: queryInterface => queryInterface.dropTable('Notification') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('Bookmark', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()') | ||
}, | ||
articleId: { | ||
allowNull: false, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()'), | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'Article', | ||
key: 'id', | ||
as: 'articleId', | ||
}, | ||
}, | ||
userId: { | ||
allowNull: false, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()'), | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'User', | ||
key: 'id', | ||
as: 'userId', | ||
}, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
}), | ||
// eslint-disable-next-line no-unused-vars | ||
down: queryInterface => queryInterface.dropTable('Bookmark') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('Comment', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()'), | ||
}, | ||
articleId: { | ||
allowNull: false, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()'), | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'Article', | ||
key: 'id', | ||
as: 'articleId', | ||
}, | ||
}, | ||
commentBody: { | ||
allowNull: { | ||
args: false, | ||
msg: 'Please write your comment?' | ||
}, | ||
type: Sequelize.TEXT | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}), | ||
down: queryInterface => queryInterface.dropTable('Comment') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('Tag', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()') | ||
}, | ||
tagText: { | ||
type: Sequelize.TEXT | ||
}, | ||
}), | ||
down: queryInterface => queryInterface.dropTable('Tag') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('TagArticle', { | ||
tagId: { | ||
allowNull: false, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()'), | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'Tag', | ||
key: 'id', | ||
as: 'tagId', | ||
}, | ||
}, | ||
articleId: { | ||
allowNull: false, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.literal('uuid_generate_v4()'), | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'Article', | ||
key: 'id', | ||
as: 'articleId', | ||
}, | ||
}, | ||
}), | ||
down: queryInterface => queryInterface.dropTable('TagArticle') | ||
}; |
Oops, something went wrong.