Skip to content

Commit

Permalink
Merge branch 'main' of github.com:tattle-made/Uli into main
Browse files Browse the repository at this point in the history
  • Loading branch information
dennyabrain committed Oct 13, 2023
2 parents bb646ea + d4ee30d commit ccaa7f5
Show file tree
Hide file tree
Showing 34 changed files with 4,255 additions and 155 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'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,
},
levelOfSeverity : {
type: Sequelize.ENUM(['low', 'medium', 'high']),
},
casual : {
type: Sequelize.BOOLEAN,
},
appropriated: {
type: Sequelize.BOOLEAN,
},
appropriationContext: {
type: Sequelize.BOOLEAN,
},
labelMeaning: {
type: Sequelize.TEXT,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('slurs');
},
};
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('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([
"gendered",
"sexualized",
"religion",
"ethnicity",
"political affiliation",
"caste",
"class",
"body shaming",
"ableist",
"sexual identity",
"other",
]),
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('categories');
},
};
47 changes: 47 additions & 0 deletions browser-extension/api-server/db/models/category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"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([
"gendered",
"sexualized",
"religion",
"ethnicity",
"political affiliation",
"caste",
"class",
"body shaming",
"ableist",
"sexual identity",
"other",
]),
},
},
{
sequelize,
modelName: "category",
}
);

return category;
};
59 changes: 59 additions & 0 deletions browser-extension/api-server/db/models/slur.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"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,
},
levelOfSeverity: {
type: DataTypes.ENUM(['low', 'medium', 'high']),
},
casual: {
type: DataTypes.BOOLEAN,
},
appropriated: {
type: DataTypes.BOOLEAN,
},
appropriationContext: {
type: DataTypes.BOOLEAN,
},
labelMeaning: {
type: DataTypes.TEXT,
},
},
{
sequelize,
modelName: "slur",
}
);

return slur;
};
1 change: 1 addition & 0 deletions browser-extension/api-server/db/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = (sequelize, DataTypes) => {
// define association here
user.hasOne(models.preference);
user.hasMany(models.post);
user.hasMany(models.slur);
}
}
user.init(
Expand Down
Loading

0 comments on commit ccaa7f5

Please sign in to comment.