making needed changes to make the table names strict

This commit is contained in:
Arjun Patel
2019-04-13 18:06:18 -07:00
parent 7fd0128864
commit 9faff9e6e8
12 changed files with 428 additions and 329 deletions
+118 -109
View File
@@ -2,121 +2,130 @@ const Cause = require('./Cause'),
Region = require('./Region');
module.exports = (sequelize, DataTypes) => {
const Organization = sequelize.define('Organization', {
id: {
type: DataTypes.UUID,
allowNull: false,
primaryKey: true
},
name: { type: DataTypes.STRING, allowNull: false },
profile_pic_url: {
type: DataTypes.STRING,
allowNull: true
},
short_description: { type: DataTypes.STRING, allowNull: false },
total_received: {
type: DataTypes.INTEGER,
defaultValue: 0
},
total_donors: {
type: DataTypes.INTEGER,
defaultValue: 0
},
stripe_account_id: {
type: DataTypes.UUID,
defaultValue: null
},
primary_contact_email: {
type: DataTypes.STRING,
validate: {
isEmail: true
const Organization = sequelize.define(
'Organization',
{
id: {
type: DataTypes.UUID,
allowNull: false,
primaryKey: true
},
name: { type: DataTypes.STRING, allowNull: false },
profile_pic_url: {
type: DataTypes.STRING,
allowNull: true
},
short_description: { type: DataTypes.STRING, allowNull: false },
total_received: {
type: DataTypes.INTEGER,
defaultValue: 0
},
total_donors: {
type: DataTypes.INTEGER,
defaultValue: 0
},
stripe_account_id: {
type: DataTypes.UUID,
defaultValue: null
},
allowNull: false,
unique: true
},
password: {
type: DataTypes.STRING,
allowNull: false
},
address: {
type: DataTypes.STRING,
allowNull: false
},
city: {
type: DataTypes.STRING,
allowNull: false
},
state: {
type: DataTypes.STRING(5),
allowNull: false
},
country: {
type: DataTypes.STRING,
defaultValue: 'USA',
allowNull: false
},
zip: {
type: DataTypes.STRING(10),
allowNull: false
},
primary_contact_email: {
type: DataTypes.STRING,
validate: {
isEmail: true
},
allowNull: false,
unique: true
},
password: {
type: DataTypes.STRING,
allowNull: false
},
primary_cause: {
type: DataTypes.STRING,
allowNull: false,
references: {
model: Cause(sequelize, DataTypes),
key: 'name'
}
},
primary_region: {
type: DataTypes.STRING,
allowNull: false,
references: {
model: Region(sequelize, DataTypes),
key: 'name'
address: {
type: DataTypes.STRING,
allowNull: false
},
city: {
type: DataTypes.STRING,
allowNull: false
},
state: {
type: DataTypes.STRING(5),
allowNull: false
},
country: {
type: DataTypes.STRING,
defaultValue: 'USA',
allowNull: false
},
zip: {
type: DataTypes.STRING(10),
allowNull: false
},
primary_cause: {
type: DataTypes.STRING,
allowNull: false,
references: {
model: Cause(sequelize, DataTypes),
key: 'name'
}
},
primary_region: {
type: DataTypes.STRING,
allowNull: false,
references: {
model: Region(sequelize, DataTypes),
key: 'name'
}
},
total_rating: { type: DataTypes.INTEGER, defaultValue: 0 },
ein: {
type: DataTypes.STRING(10),
allowNull: false
},
estimate_asset_value: {
type: DataTypes.BIGINT,
defaultValue: 0
},
estimate_yearly_operating_cost: {
type: DataTypes.BIGINT,
defaultValue: 0
},
is_nonprofit: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
is_verified: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
primary_contact_phone: {
type: DataTypes.STRING(20),
allowNull: false
},
primary_contact_first_name: {
type: DataTypes.STRING,
allowNull: false
},
primary_contact_last_name: {
type: DataTypes.STRING,
allowNull: false
}
},
{
freezeTableName: true,
total_rating: { type: DataTypes.INTEGER, defaultValue: 0 },
ein: {
type: DataTypes.STRING(10),
allowNull: false
},
estimate_asset_value: {
type: DataTypes.BIGINT,
defaultValue: 0
},
estimate_yearly_operating_cost: {
type: DataTypes.BIGINT,
defaultValue: 0
},
is_nonprofit: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
is_verified: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
primary_contact_phone: {
type: DataTypes.STRING(20),
allowNull: false
},
primary_contact_first_name: {
type: DataTypes.STRING,
allowNull: false
},
primary_contact_last_name: {
type: DataTypes.STRING,
allowNull: false
// define the table's name
tableName: 'organizations'
}
});
);
return Organization;
};