Hi @anon94532230
Yes they are in the .forestadmin-schema.json file
Below is an example of behavior:
Table with relationship:
CREATE TABLE parcel_contracts (
id bigserial NOT NULL,
parcel_id int4 NULL,
contract_id int4 NULL,
created_at timestamp NOT NULL,
updated_at timestamp NOT NULL,
CONSTRAINT parcel_contracts_pkey PRIMARY KEY (id),
CONSTRAINT fk_rails_43e35cb79b FOREIGN KEY (contract_id) REFERENCES public.contracts(id),
CONSTRAINT fk_rails_d0da44fdd0 FOREIGN KEY (parcel_id) REFERENCES public.parcels(id)
);
Front model file:
// 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 ParcelContracts = sequelize.define('parcelContracts', {
createdAt: {
type: DataTypes.DATE,
},
updatedAt: {
type: DataTypes.DATE,
},
}, {
tableName: 'parcel_contracts',
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.
ParcelContracts.associate = (models) => {
ParcelContracts.belongsTo(models.contracts, {
foreignKey: {
name: 'contractIdKey',
field: 'contract_id',
},
as: 'contract',
});
ParcelContracts.belongsTo(models.parcels, {
foreignKey: {
name: 'parcelIdKey',
field: 'parcel_id',
},
as: 'parcel',
});
};
return ParcelContracts;
};
New file:
// This model was generated by Forest CLI. 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 ParcelContracts = sequelize.define('parcelContracts', {
parcelId: {
type: DataTypes.INTEGER,
},
contractId: {
type: DataTypes.INTEGER,
},
createdAt: {
type: DataTypes.DATE,
},
updatedAt: {
type: DataTypes.DATE,
},
}, {
tableName: 'parcel_contracts',
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.
ParcelContracts.associate = (models) => {
};
return ParcelContracts;
};
Is it normal?