-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from FACG4/db-basic-steup
- Loading branch information
Showing
5 changed files
with
111 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import models from '../models/index'; | ||
|
||
models.sequelize | ||
.authenticate() | ||
.then(() => { | ||
console.log('Connection has been established successfully.'); | ||
}) | ||
.catch((err) => { | ||
console.error('Unable to connect to the database:', err); | ||
}); | ||
|
||
models.sequelize.sync({ force: true }).then(async () => { | ||
await models.Admin.create({ | ||
username: 'admin', | ||
password: 'admin', | ||
email: '[email protected]' | ||
}); | ||
|
||
await models.Flights.bulkCreate([ | ||
{ | ||
airline: 'Gaza Airlines', | ||
airport: 'Gaza Airport', | ||
flight_no: 'GA001', | ||
origin: 'Gaza', | ||
destination: 'Berlin', | ||
departure_time: '09-15-2018 22:00:00', | ||
arrival_time: '09-16-2018 09:00:00', | ||
gate: 'W-10', | ||
aircraft: 'BW', | ||
}, | ||
{ | ||
airline: 'Nigeria Airlines', | ||
airport: 'Lagos', | ||
flight_no: 'NA001', | ||
origin: 'Lagos', | ||
destination: 'Aboja', | ||
departure_time: '09-15-2018 22:00:00', | ||
arrival_time: '09-16-2018 09:00:00', | ||
gate: 'W-10', | ||
aircraft: 'BW', | ||
}, | ||
|
||
]); | ||
await models.Customers.bulkCreate([ | ||
{ | ||
first_name: 'Abdalsamad', | ||
last_name: 'Abumusameh', | ||
email: '[email protected]', | ||
phone: '0599194310', | ||
notify_me: true, | ||
flight_id: 1 | ||
}, | ||
{ | ||
first_name: 'Balsam', | ||
last_name: 'Ashi', | ||
email: '[email protected]', | ||
phone: '0599000001', | ||
notify_me: true, | ||
flight_id: 1 | ||
}, | ||
{ | ||
first_name: 'Inass', | ||
last_name: 'T.', | ||
email: '[email protected]', | ||
phone: '05990000002', | ||
notify_me: false, | ||
flight_id: 1 | ||
}, | ||
{ | ||
first_name: 'Ramy', | ||
last_name: 'Shurafa', | ||
email: '[email protected]', | ||
phone: '05990000003', | ||
notify_me: true, | ||
flight_id: 1 | ||
}, | ||
{ | ||
first_name: 'John', | ||
last_name: 'Rees', | ||
email: '[email protected]', | ||
phone: '05990000004', | ||
notify_me: true, | ||
flight_id: 2 | ||
}, | ||
{ | ||
first_name: 'Root', | ||
last_name: 'Sam', | ||
email: '[email protected]', | ||
phone: '05990000006', | ||
notify_me: true, | ||
flight_id: 2 | ||
}, | ||
{ | ||
first_name: 'Finch', | ||
last_name: 'H.', | ||
email: '[email protected]', | ||
phone: '05990000009', | ||
notify_me: true, | ||
flight_id: 2 | ||
}, | ||
]); | ||
await models.sequelize.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters