41 lines
822 B
JavaScript
41 lines
822 B
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../config/db');
|
|
|
|
const Booking = sequelize.define('booking', {
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
primaryKey: true,
|
|
autoIncrement: true
|
|
},
|
|
userId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
references: {
|
|
model: 'users',
|
|
key: 'id'
|
|
}
|
|
},
|
|
gymClassId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
references: {
|
|
model: 'gymclasses',
|
|
key: 'id'
|
|
}
|
|
},
|
|
bookingDate: {
|
|
type: DataTypes.DATE,
|
|
defaultValue: DataTypes.NOW
|
|
},
|
|
status: {
|
|
type: DataTypes.STRING,
|
|
defaultValue: 'confirmed',
|
|
validate: {
|
|
isIn: [['confirmed', 'cancelled', 'pending']]
|
|
}
|
|
}
|
|
}, {
|
|
tableName: 'bookings' // Explicitly set lowercase table name
|
|
});
|
|
|
|
module.exports = Booking; |