-
Notifications
You must be signed in to change notification settings - Fork 6
/
db.js
79 lines (72 loc) · 1.62 KB
/
db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// -------- Production heroku ----------
const Sequelize = require('sequelize');
const db = new Sequelize('heroku_d806c6567391c01', 'b0b3a0a85c2dbc', '28875add', {
host: 'us-cdbr-iron-east-01.cleardb.net',
dialect: 'mysql',
pool:{
min: 0,
max: 5
}
});
// -------- Development --------
// const Sequelize = require('sequelize')
// const db = new Sequelize('ticketing', 'gaurav_ticketing', 'Ticketing 1', {
// host: 'localhost',
// dialect: 'mysql',
// pool: {
// min: 0,
// max: 5,
// }
// })
const Movie = db.define('movies', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
seats_A: {
type: Sequelize.INTEGER
},
seats_B: {
type: Sequelize.INTEGER
},
seats_D: {
type: Sequelize.INTEGER
}
});
const Seat = db.define('aisle_seats', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true
},
movie_id: {
type: Sequelize.INTEGER,
allowNull: false
},
seat_num: {
type: Sequelize.INTEGER,
allowNull: false
},
row_name: {
type: Sequelize.STRING,
allowNull: false
},
is_aisle: {
type: Sequelize.BOOLEAN,
defaultValue: false
},
is_reserved: {
type: Sequelize.BOOLEAN,
defaultValue: false
}
});
db.sync().then(() => console.log("Database has been synced! "))
.catch((err) => console.log("Error creating database! "));
exports = module.exports = {
Seat, Movie
};