const { sequelize } = require('../config/db');

const User = require('./user');
const PetGroup = require('./PetGroup');
const PetSpecies = require('./PetSpecies');
const PetBreed = require('./PetBreed');
const PetDisease = require('./PetDisease');
const Pet = require('./Pet');
const Schedule = require('./Schedule');

// Associations

// Master Data Relationships
PetGroup.hasMany(PetSpecies, { foreignKey: 'groupId' });
PetSpecies.belongsTo(PetGroup, { foreignKey: 'groupId' });

PetSpecies.hasMany(PetBreed, { foreignKey: 'speciesId' });
PetBreed.belongsTo(PetSpecies, { foreignKey: 'speciesId' });

// User <-> Pet
User.hasMany(Pet, { foreignKey: 'userId' });
Pet.belongsTo(User, { foreignKey: 'userId' });

// Pet <-> Schedule
Pet.hasMany(Schedule, { foreignKey: 'petId' });
Schedule.belongsTo(Pet, { foreignKey: 'petId' });


module.exports = {
  sequelize,
  User,
  PetGroup,
  PetSpecies,
  PetBreed,
  PetDisease,
  Pet,
  Schedule,
};
