import Client from './client.js';
import ClientwiseFeatures from './clientwiseFeatures.js';
import Treelogy from './treelogy.js';
import Dbname from './dbname.js';
import Login from './login.js';
import Mapping from './mapping.js';
import DashboardVisibility from './dashboardVisibility.js';
import UserMaster from './userMaster.js';
import Form from './form.js';

// Client ↔ Treelogy
Client.hasMany(Treelogy, { foreignKey: 'client_id' });
Treelogy.belongsTo(Client, { foreignKey: 'client_id' });

// Client ↔ ClientwiseFeatures (1:1 or 1:many; your table allows many)
Client.hasMany(ClientwiseFeatures, { foreignKey: 'client_id' });
ClientwiseFeatures.belongsTo(Client, { foreignKey: 'client_id' });

// Treelogy ↔ Dbname
Treelogy.hasMany(Dbname, { foreignKey: 'treelogy_id' });
Dbname.belongsTo(Treelogy, { foreignKey: 'treelogy_id' });

// Client/Treelogy ↔ Login
Client.hasMany(Login, { foreignKey: 'client_id' });
Login.belongsTo(Client, { foreignKey: 'client_id' });

Treelogy.hasMany(Login, { foreignKey: 'treelogy_id' });
Login.belongsTo(Treelogy, { foreignKey: 'treelogy_id' });

// Login/Treelogy ↔ Mapping
Login.hasMany(Mapping, { foreignKey: 'login_id' });
Mapping.belongsTo(Login, { foreignKey: 'login_id' });

Treelogy.hasMany(Mapping, { foreignKey: 'treelogy_id' });
Mapping.belongsTo(Treelogy, { foreignKey: 'treelogy_id' });

// Treelogy ↔ DashboardVisibility
Treelogy.hasMany(DashboardVisibility, { foreignKey: 'treelogy_id' });
DashboardVisibility.belongsTo(Treelogy, { foreignKey: 'treelogy_id' });

// UserMaster ↔ Login
UserMaster.hasMany(Login, { foreignKey: 'role_id' });
Login.belongsTo(UserMaster, { foreignKey: 'role_id' });

// (Optional) If unit is another table later, map unit_id there.
export {
  Client, ClientwiseFeatures, Treelogy, Dbname, Login, Mapping, DashboardVisibility, UserMaster, Form
};
