-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'slur-crowdsource' of https://github.com/aatmanvaidya/Uli …
…into slur-crowdsource
- Loading branch information
Showing
16 changed files
with
673 additions
and
36 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
browser-extension/api-server/db/migrations/20230906084000-create-slur.js
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,48 @@ | ||
'use strict'; | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
await queryInterface.createTable('slurs', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.UUIDV4, | ||
}, | ||
userId: { | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.UUIDV4, | ||
references: { | ||
model:'users', | ||
key: 'id', | ||
} | ||
}, | ||
label: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
}, | ||
labelMeaning: { | ||
type: Sequelize.TEXT, | ||
allowNull: false, | ||
}, | ||
appropriated: { | ||
type: Sequelize.BOOLEAN, | ||
allowNull: false, | ||
}, | ||
appropriationContext: { | ||
type: Sequelize.STRING, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
}, | ||
}); | ||
}, | ||
|
||
down: async (queryInterface, Sequelize) => { | ||
await queryInterface.dropTable('slurs'); | ||
}, | ||
}; |
37 changes: 37 additions & 0 deletions
37
browser-extension/api-server/db/migrations/20230906085000-create-category.js
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,37 @@ | ||
'use strict'; | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
await queryInterface.createTable('categories', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.UUIDV4, | ||
}, | ||
slurId: { | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.UUIDV4, | ||
references: { | ||
model: 'slurs', | ||
key: 'id', | ||
}, | ||
}, | ||
category: { | ||
type: Sequelize.ENUM(['gender', 'religion', 'caste']), | ||
allowNull: false, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
}, | ||
}); | ||
}, | ||
|
||
down: async (queryInterface, Sequelize) => { | ||
await queryInterface.dropTable('categories'); | ||
}, | ||
}; |
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,36 @@ | ||
"use strict"; | ||
const { Model } = require("sequelize"); | ||
|
||
module.exports = (sequelize, DataTypes) => { | ||
class category extends Model { | ||
static associate(models) { | ||
// Define associations here if needed | ||
} | ||
} | ||
|
||
category.init( | ||
{ | ||
id: { | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4, | ||
}, | ||
slurId: { | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4, | ||
foreignKey: true, | ||
allowNull: false, | ||
}, | ||
category : { | ||
type: DataTypes.ENUM(['gender', 'religion', 'caste']), | ||
allowNull: false, | ||
}, | ||
}, | ||
{ | ||
sequelize, | ||
modelName: "category", | ||
} | ||
); | ||
|
||
return 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,56 @@ | ||
"use strict"; | ||
const { Model } = require("sequelize"); | ||
|
||
module.exports = (sequelize, DataTypes) => { | ||
class slur extends Model { | ||
/** | ||
* Helper method for defining associations. | ||
* This method is not a part of Sequelize lifecycle. | ||
* The `models/index` file will call this method automatically. | ||
*/ | ||
static associate(models) { | ||
// Define associations here if needed | ||
slur.hasMany(models.category, { | ||
foreignKey: "slurId", | ||
as: "categories", | ||
}); | ||
} | ||
} | ||
|
||
slur.init( | ||
{ | ||
id: { | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4, | ||
}, | ||
userId:{ | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4, | ||
foreignKey: true, | ||
allowNull: false, | ||
}, | ||
label: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
labelMeaning: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
}, | ||
appropriated: { | ||
type: DataTypes.BOOLEAN, | ||
allowNull: false, | ||
}, | ||
appropriationContext: { | ||
type: DataTypes.STRING, | ||
}, | ||
}, | ||
{ | ||
sequelize, | ||
modelName: "slur", | ||
} | ||
); | ||
|
||
return slur; | ||
}; |
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
Oops, something went wrong.