Commit 619844f9 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

Merge branch 'jiwon'

parents 3d810a85 2cb5ab29
...@@ -4,6 +4,8 @@ import RoleModel from "../models/role.model.js"; ...@@ -4,6 +4,8 @@ import RoleModel from "../models/role.model.js";
import MovieModel from "../models/movie.model.js"; import MovieModel from "../models/movie.model.js";
import CinemaModel from "../models/cinema.model.js"; import CinemaModel from "../models/cinema.model.js";
import TheaterModel from "../models/theater.model.js"; import TheaterModel from "../models/theater.model.js";
import TimeTableModel from '../models/role.model.js';
import ReservationModel from '../models/reservation.model.js';
import dbConfig from "../config/db.config.js"; import dbConfig from "../config/db.config.js";
const sequelize = new Sequelize( const sequelize = new Sequelize(
...@@ -27,6 +29,8 @@ const Role = RoleModel(sequelize) ...@@ -27,6 +29,8 @@ const Role = RoleModel(sequelize)
const Movie = MovieModel(sequelize) const Movie = MovieModel(sequelize)
const Cinema = CinemaModel(sequelize) const Cinema = CinemaModel(sequelize)
const Theater = TheaterModel(sequelize) const Theater = TheaterModel(sequelize)
const TimeTable = TimeTableModel(sequelize)
const Reservation = ReservationModel(sequelize)
User.belongsTo(Role); User.belongsTo(Role);
Role.hasOne(User); Role.hasOne(User);
...@@ -40,5 +44,7 @@ export { ...@@ -40,5 +44,7 @@ export {
Role, Role,
Movie, Movie,
Cinema, Cinema,
Theater Theater,
TimeTable,
Reservation
} }
\ No newline at end of file
...@@ -10,7 +10,7 @@ dotenv.config({ ...@@ -10,7 +10,7 @@ dotenv.config({
}); });
sequelize sequelize
.sync({ force: true }) .sync({ force: false })
.then(async () => { .then(async () => {
await Promise.all( await Promise.all(
Object.keys(ROLE_NAME).map((name) => { Object.keys(ROLE_NAME).map((name) => {
......
import Sequelize from "sequelize";
const { DataTypes } = Sequelize;
const ReservationModel = (sequelize) => {
const Reservation = sequelize.define(
"reservation",
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
movieId: {
type: DataTypes.INTEGER,
},
theater: {
type: DataTypes.INTEGER,
},
row: {
type: DataTypes.STRING,
},
col: {
type: DataTypes.INTEGER,
},
timetable:{
type: DataTypes.INTEGER,
},
user:{
type: DataTypes.INTEGER,
},
payment:{
type: DataTypes.INTEGER,
}
},
{
timestamps: true,
freezeTableName: true,
tableName: "reservations"
}
);
return Reservation;
};
export default ReservationModel;
\ No newline at end of file
import Sequelize from "sequelize";
const { DataTypes } = Sequelize;
const TimeTableModel = (sequelize) => {
const TimeTable = sequelize.define(
"timetable",
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
theater: {
type: DataTypes.INTEGER,
},
movieId: {
type: DataTypes.INTEGER,
},
title: {
type: DataTypes.STRING,
},
release_date: {
type: DataTypes.STRING
},
date: {
type: DataTypes.STRING,
},
time: {
type: DataTypes.TIME,
},
},
{
// timestamps: true,
freezeTableName: true,
tableName: "timetables"
}
);
return TimeTable;
};
export default TimeTableModel;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment