Same old same oldā¦ I honestly think it doesnāt go any further than this :
My models definition :
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const Integrations = sequelize.define('integrations', {
displayName: {
type: DataTypes.STRING,
defaultValue: "",
allowNull: false,
},
score: {
type: DataTypes.INTEGER,
},
createdAt: {
type: DataTypes.DATE,
},
updatedAt: {
type: DataTypes.DATE,
},
numberOfLots: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false,
},
numberOfBuildings: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false,
},
sergicId: {
type: DataTypes.INTEGER,
},
sergicUpdateTime: {
type: DataTypes.DATE,
},
openReportCount: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false,
},
icsCode: {
type: DataTypes.STRING,
},
pictureName: {
type: DataTypes.STRING,
},
sergicOffer: {
type: DataTypes.ENUM(['DIR', 'ESE', 'VSY']),
defaultValue: "",
},
sergicIdFull: {
type: DataTypes.STRING,
},
individualized: {
type: DataTypes.BOOLEAN,
},
separated: {
type: DataTypes.BOOLEAN,
},
temporary: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
inviteStatus: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
inviteUrl: {
type: DataTypes.STRING,
},
wpCode: {
type: DataTypes.STRING,
},
synchronizedWithSergicAt: {
type: DataTypes.DATE,
},
fiscalYearMonth: {
type: DataTypes.INTEGER
},
description: {
type: DataTypes.STRING,
},
support247: {
type: DataTypes.BOOLEAN,
field: 'support_24_7',
defaultValue: false,
},
workAdvance: {
type: DataTypes.INTEGER,
},
firstRegulation: {
type: DataTypes.DATE,
},
siret: {
type: DataTypes.STRING,
},
serviceResidence: {
type: DataTypes.BOOLEAN,
},
cooperativeSyndicate: {
type: DataTypes.BOOLEAN,
},
principalSyndicate: {
type: DataTypes.BOOLEAN,
},
constructionPeriod: {
type: DataTypes.ENUM([
'before_1949',
'from_1949_to_1960',
'from_1961_to_1974',
'from_1975_to_1993',
'from_1994_to_2000',
'from_2001_to_2010',
'after_2011',
'unknown'
]),
},
canTalk: {
type: DataTypes.BOOLEAN,
defaultValue: true,
},
integrationState: {
type: DataTypes.ENUM([
'new', // Nouveau : Docs.en attente
'awaiting_document_validation', // Documents Ć valider
'management_integration', // IntƩgration gestion
'awaiting_budget_validation', // Attente validation budget
'send_report', // Rattachement & PV Ć envoyer
'invalid_budget', // Budget refusĆ© Ć revoir
'sage', // IntƩgration Comptable - SAGE
'awaiting_archives', // Attente archives
'done', // Actif
'pending_lost', // A transferer
'lost' // Immeuble perdu
]),
},
historicalMonument: {
type: DataTypes.BOOLEAN,
},
loan: {
type: DataTypes.BOOLEAN,
},
registrationNumber: {
type: DataTypes.STRING,
},
kind: {
type: DataTypes.ENUM([
'habitation',
'mixed',
'asl',
'parking',
'commercial'
])
},
orderPerilStartDate: {
type: DataTypes.DATEONLY,
},
orderPerilEndDate: {
type: DataTypes.DATEONLY,
},
dtg: {
type: DataTypes.BOOLEAN,
},
dpe: {
type: DataTypes.STRING,
},
generalMeetingDate: {
type: DataTypes.DATEONLY,
},
difficulty: {
type: DataTypes.BOOLEAN,
},
energyAudit: {
type: DataTypes.BOOLEAN,
},
deletedAt: {
type: DataTypes.BOOLEAN,
},
coownershipRegistrationDate: {
type: DataTypes.DATE,
},
}, {
tableName: 'places',
underscored: true,
schema: process.env.DATABASE_SCHEMA,
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
Integrations.associate = (models) => {
Integrations.belongsTo(models.agencies, {
foreignKey: {
name: 'agencyIdKey',
field: 'agency_id',
},
as: 'agency',
});
Integrations.belongsToMany(models.accountPlaces, {
through: 'treasuries',
foreignKey: 'place_id',
otherKey: 'account_place_id',
as: 'accountPlacesThroughTreasuries',
});
Integrations.hasMany(models.integrationBudgets, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'integrationBudgets',
});
Integrations.hasMany(models.parcels, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'parcels',
});
Integrations.hasMany(models.contracts, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'contracts',
});
Integrations.hasMany(models.entryCodes, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'entryCodes',
});
Integrations.hasMany(models.votedWorks, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'votedWorks',
});
Integrations.hasMany(models.reports, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'reports',
});
Integrations.hasMany(models.conversations, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'conversations',
});
Integrations.hasMany(models.maintenanceWorks, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'maintenanceWorks',
});
Integrations.hasMany(models.managementMandates, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'managementMandates',
});
Integrations.hasMany(models.maintenanceContracts, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'maintenanceContracts',
});
Integrations.hasMany(models.managementFees, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'managementFees',
});
Integrations.hasMany(models.equipment, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'equipment',
});
Integrations.hasMany(models.fiscalYears, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'fiscalYears',
});
Integrations.hasMany(models.publicWorks, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'publicWorks',
});
Integrations.hasMany(models.propertyRepresentatives, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'propertyRepresentatives',
});
Integrations.hasMany(models.alerts, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'alerts',
});
Integrations.hasMany(models.accountPlaceEntries, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'accountPlaceEntries',
});
Integrations.hasMany(models.allocatedBudgets, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'allocatedBudgets',
});
Integrations.hasMany(models.buildings, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'buildings',
});
Integrations.hasMany(models.notifications, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'notifications',
});
Integrations.hasMany(models.generalMeetings, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'generalMeetings',
});
Integrations.hasMany(models.repartitionKeys, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'repartitionKeys',
});
Integrations.hasMany(models.topics, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'topics',
});
Integrations.hasMany(models.serviceOrders, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'serviceOrders',
});
Integrations.hasMany(models.connectedDeviceAlerts, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'connectedDeviceAlerts',
});
Integrations.hasMany(models.previousManagementAgents, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'previousManagementAgents',
});
Integrations.hasMany(models.defaultIdentities, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'defaultIdentities',
});
Integrations.hasMany(models.feedEvents, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'feedEvents',
});
Integrations.hasMany(models.workOrders, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'workOrders',
});
Integrations.hasMany(models.placeEmployees, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'placeEmployees',
});
Integrations.hasMany(models.rssFeeds, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'rssFeeds',
});
Integrations.hasMany(models.coownershipFolders, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'coownershipFolders',
});
Integrations.hasMany(models.billers, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'billers',
});
Integrations.hasMany(models.decisions, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'decisions',
});
Integrations.hasMany(models.integrationDocuments, {
foreignKey: {
name: 'placeIdKey',
field: 'place_id',
},
as: 'integrationDocuments',
});
};
return Integrations;
};
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const Roles = sequelize.define('roles', {
name: {
type: DataTypes.ENUM([
'director',
'director_assistant',
'coowner_accountant',
'recovery_responsible',
'claims_manager',
'property_developer',
'coowner_manager',
'coowner_assistant',
'sergic_partner_admin',
'sergic_partner',
'biller_reviewer',
'president_board_member',
'coownership_board_member',
'coowner',
'coowner_secondary',
'lessor',
'tenant',
'caretaker',
'employee',
'representative'
]),
},
resourceType: {
type: DataTypes.STRING,
},
resourceId: {
type: DataTypes.BIGINT,
},
createdAt: {
type: DataTypes.DATE,
},
updatedAt: {
type: DataTypes.DATE,
},
}, {
tableName: 'roles',
underscored: true,
schema: process.env.DATABASE_SCHEMA,
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
Roles.associate = (models) => {
Roles.belongsToMany(models.identities, {
through: 'identitiesRoles',
foreignKey: 'role_id',
otherKey: 'identity_id',
as: 'identitiesThroughIdentitiesRoles',
});
};
return Roles;
};
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const IdentitiesRoles = sequelize.define('identitiesRoles', {
}, {
tableName: 'identities_roles',
underscored: true,
timestamps: false,
schema: process.env.DATABASE_SCHEMA,
});
IdentitiesRoles.removeAttribute('id');
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
IdentitiesRoles.associate = (models) => {
IdentitiesRoles.belongsTo(models.roles, {
foreignKey: {
name: 'roleIdKey',
field: 'role_id',
},
as: 'role',
});
IdentitiesRoles.belongsTo(models.identities, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'identity',
});
};
return IdentitiesRoles;
};
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const Identities = sequelize.define('identities', {
sergicId: {
type: DataTypes.STRING,
},
phoneNumber: {
type: DataTypes.STRING,
},
phoneChecked: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
firstName: {
type: DataTypes.STRING,
},
lastName: {
type: DataTypes.STRING,
allowNull: false,
},
email: {
type: DataTypes.STRING,
},
title: {
type: DataTypes.ENUM([
'ADM',
'ASL',
'ASS.',
'BQE',
'CAB',
'CIE',
'CLUB',
'DOCT',
'EIRL',
'ETS',
'EURL',
'GIE',
'GRPE',
'INDI',
'M&ME',
'M/ME',
'MLE',
'MME',
'MMES',
'MMM',
'MR',
'MRS',
'MTRE',
'NOT.',
'SA',
'SARL',
'SAS',
'SC',
'SCCV',
'SCI',
'SCM',
'SCP',
'SCPI',
'SEM',
'SNC',
'SPE',
'STE',
'SUCC',
'SYND'
]),
},
sergicUpdateTime: {
type: DataTypes.DATE,
},
birthDate: {
type: DataTypes.DATE,
},
invited: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
createdAt: {
type: DataTypes.DATE,
},
updatedAt: {
type: DataTypes.DATE,
},
realName: {
type: DataTypes.STRING,
},
homePhone: {
type: DataTypes.STRING,
},
representative: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
legalKind: {
type: DataTypes.ENUM(['natural_person', 'legal_entity']),
defaultValue: "natural_person",
},
}, {
tableName: 'identities',
underscored: true,
schema: process.env.DATABASE_SCHEMA,
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
Identities.associate = (models) => {
Identities.belongsTo(models.users, {
foreignKey: {
name: 'userIdKey',
field: 'user_id',
},
as: 'user',
});
Identities.belongsToMany(models.agencies, {
through: 'identityAgencies',
foreignKey: 'identity_id',
otherKey: 'agency_id',
as: 'agenciesThroughIdentityAgencies',
});
Identities.belongsToMany(models.roles, {
through: 'identitiesRoles',
foreignKey: 'identity_id',
otherKey: 'role_id',
as: 'rolesThroughIdentitiesRoles',
});
Identities.hasMany(models.contracts, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'contracts',
});
Identities.hasMany(models.accountPlaceEntries, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'accountPlaceEntries',
});
Identities.hasMany(models.attendances, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'attendances',
});
Identities.hasMany(models.votes, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'votes',
});
Identities.hasMany(models.generalMeetingEvents, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'generalMeetingEvents',
});
Identities.hasMany(models.generalMeetingDocuments, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'generalMeetingDocuments',
});
Identities.hasMany(models.documentSignatures, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'documentSignatures',
});
Identities.hasMany(models.serviceOrders, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'serviceOrders',
});
Identities.hasMany(models.previousManagementAgents, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'previousManagementAgents',
});
Identities.hasMany(models.identityRepartitionKeys, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'identityRepartitionKeys',
});
Identities.hasMany(models.defaultIdentities, {
foreignKey: {
name: 'identityIdKey',
field: 'identity_id',
},
as: 'defaultIdentities',
});
Identities.hasMany(models.addresses, {
foreignKey: {
name: 'identityIdKey',
field: 'addressable_id',
},
as: 'addresses',
});
};
return Identities;
};