synt_backend
Version:
Synt light-weight node backend service
359 lines (356 loc) • 8.38 kB
JavaScript
"use strict";
module.exports = {
up: async (queryInterface) => {
await queryInterface.bulkInsert("Companies", [
{
country_code: "BE",
company_number: "0727451993",
name: "VERENIGING VAN MEDEEIGENAARS RESIDENTIE ZAAL ASTRID TE TERNAT, MARKTPLEIN 2",
address: "Marktplein 2 1740 Ternat",
current_account: "BE12 1234 4321 1234",
createdAt: new Date(),
updatedAt: new Date(),
},
{
country_code: "BE",
company_number: "0695578387",
name: "VERENIGING VAN MEDEEIGENAARS VAN RESIDENTIE DE HERTOG, POODTSTRAAT 1 EN PRIEELSTRAAT 4 TE TERNAT",
address: "Poodtstraat 1 1740 Ternat",
current_account: "BE12 1234 4321 1234",
createdAt: new Date(),
updatedAt: new Date(),
},
{
country_code: "BE",
company_number: "0455294343",
name: "BoxCox",
address: "Assestraat 11 1790 Affligem",
phone: "0485660432",
current_account: "BE12 1234 4321 1234",
createdAt: new Date(),
updatedAt: new Date(),
},
]);
const AstridCompanyId = await queryInterface.rawSelect(
"Companies",
{
where: {
company_number: "0727451993",
},
},
["id"]
);
const HertogCompanyId = await queryInterface.rawSelect(
"Companies",
{
where: {
company_number: "0695578387",
},
},
["id"]
);
const SupplierCompanyId = await queryInterface.rawSelect(
"Companies",
{
where: {
name: "BoxCox",
},
},
["id"]
);
await queryInterface.bulkInsert("VMEs", [
{
CompanyId: AstridCompanyId,
alias: "Zaal Astrid",
total_shares: 10000,
financial_year_starts_at: new Date(2021, 6, 1, 12),
createdAt: new Date(),
updatedAt: new Date(),
},
{
CompanyId: HertogCompanyId,
alias: "De Hertog",
total_shares: 10000,
financial_year_starts_at: new Date(2021, 6, 1, 12),
createdAt: new Date(),
updatedAt: new Date(),
},
]);
const VMEId = await queryInterface.rawSelect(
"VMEs",
{
where: {
alias: "Zaal Astrid",
},
},
["id"]
);
const HertogVMEId = await queryInterface.rawSelect(
"VMEs",
{
where: {
alias: "De Hertog",
},
},
["id"]
);
await queryInterface.bulkInsert("Users", [
{
first_name: "Marie",
last_name: "Heeremans",
email: "marie@synt.be",
is_admin: false,
email_verified_at: new Date(),
address: "Assestraat 11, 1790 Affligem",
createdAt: new Date(),
updatedAt: new Date(),
},
{
first_name: "Leontine",
last_name: "Snelders",
email: "leontine@synt.be",
address: "Assestraat 11, 1790 Affligem",
is_admin: false,
email_verified_at: new Date(),
createdAt: new Date(),
updatedAt: new Date(),
},
{
first_name: "Adriaan",
last_name: "De Bolle",
email: "adriaan@synt.be",
address: "Assestraat 11, 1790 Affligem",
is_admin: false,
email_verified_at: new Date(),
createdAt: new Date(),
updatedAt: new Date(),
},
]);
const AdminId = await queryInterface.rawSelect(
"Users",
{
where: {
email: "adriaandebolle@gmail.com",
},
},
["id"]
);
const AdriaanId = await queryInterface.rawSelect(
"Users",
{
where: {
email: "adriaan@synt.be",
},
},
["id"]
);
const MarieId = await queryInterface.rawSelect(
"Users",
{
where: {
email: "marie@synt.be",
},
},
["id"]
);
const LeontineId = await queryInterface.rawSelect(
"Users",
{
where: {
email: "leontine@synt.be",
},
},
["id"]
);
await queryInterface.bulkInsert("UserVME", [
{
UserId: AdriaanId,
VMEId,
createdAt: new Date(),
updatedAt: new Date(),
},
{
UserId: MarieId,
VMEId,
createdAt: new Date(),
updatedAt: new Date(),
},
{
UserId: LeontineId,
VMEId,
createdAt: new Date(),
updatedAt: new Date(),
},
]);
await queryInterface.bulkInsert("UserVME", [
{
UserId: AdminId,
VMEId: HertogVMEId,
createdAt: new Date(),
updatedAt: new Date(),
},
{
UserId: AdriaanId,
VMEId: HertogVMEId,
createdAt: new Date(),
updatedAt: new Date(),
},
]);
await queryInterface.bulkInsert("Lots", [
{
UserId: AdriaanId,
VMEId,
name: "Topfloor Mansion",
share: 5000,
is_common: 0,
createdAt: new Date(),
updatedAt: new Date(),
},
{
UserId: AdriaanId,
VMEId,
name: "B&B Appartement",
share: 2000,
is_common: 0,
createdAt: new Date(),
updatedAt: new Date(),
},
{
UserId: MarieId,
VMEId,
name: "Loft",
share: 2000,
is_common: 0,
createdAt: new Date(),
updatedAt: new Date(),
},
{
UserId: LeontineId,
VMEId,
name: "Appartement",
share: 1000,
is_common: 0,
createdAt: new Date(),
updatedAt: new Date(),
},
{
UserId: null,
VMEId,
name: "Inkomhal",
share: 0,
is_common: 1,
createdAt: new Date(),
updatedAt: new Date(),
},
]);
const LotId1 = await queryInterface.rawSelect(
"Lots",
{
where: {
name: "Topfloor Mansion",
},
},
["id"]
);
const LotIdBB = await queryInterface.rawSelect(
"Lots",
{
where: {
name: "B&B Appartement",
},
},
["id"]
);
const LotId2 = await queryInterface.rawSelect(
"Lots",
{
where: {
name: "Loft",
},
},
["id"]
);
const LotId3 = await queryInterface.rawSelect(
"Lots",
{
where: {
name: "Appartement",
},
},
["id"]
);
await queryInterface.bulkInsert("LotPhases", [
{
LotId: LotId1,
starts_at: "2021/01/01",
createdAt: new Date(),
updatedAt: new Date(),
},
{
LotId: LotId2,
starts_at: "2021/01/01",
createdAt: new Date(),
updatedAt: new Date(),
},
{
LotId: LotId2,
starts_at: "2021/01/01",
createdAt: new Date(),
updatedAt: new Date(),
},
]);
const LotPhaseId1 = await queryInterface.rawSelect(
"LotPhases",
{
where: {
LotId: LotId1,
},
},
["id"]
);
const LotPhaseId2 = await queryInterface.rawSelect(
"LotPhases",
{
where: {
LotId: LotId2,
},
},
["id"]
);
await queryInterface.bulkInsert("LotPhaseUser", [
{
UserId: AdriaanId,
LotPhaseId: LotPhaseId1,
type: "owner",
is_commissioner: 1,
createdAt: new Date(),
updatedAt: new Date(),
},
{
UserId: MarieId,
LotPhaseId: LotPhaseId2,
type: "owner",
is_commissioner: 1,
createdAt: new Date(),
updatedAt: new Date(),
},
]);
await queryInterface.bulkInsert("Suppliers", [
{
VMEId,
CompanyId: SupplierCompanyId,
createdAt: new Date(),
updatedAt: new Date(),
},
]);
},
down: async (queryInterface) => {
//await queryInterface.bulkDelete("LotUser", null, {});
await queryInterface.bulkDelete("Lots", null, {});
await queryInterface.bulkDelete("UserVME", null, {});
await queryInterface.bulkDelete("Companies", null, {});
await queryInterface.bulkDelete("Incidents", null, {});
await queryInterface.bulkDelete("Suppliers", null, {});
await queryInterface.bulkDelete("VMEs", null, {});
},
};