771 lines
18 KiB
JavaScript
771 lines
18 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Balances = db.balances;
|
|
|
|
const Comptes = db.comptes;
|
|
|
|
const Grandlivres = db.grandlivres;
|
|
|
|
const Journaux = db.journaux;
|
|
|
|
const Entreprises = db.entreprises;
|
|
|
|
const BalancesData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
solde_debiteur: 5000,
|
|
|
|
solde_crediteur: 0,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
solde_debiteur: 0,
|
|
|
|
solde_crediteur: 1500,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
solde_debiteur: 1000,
|
|
|
|
solde_crediteur: 0,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
solde_debiteur: 0,
|
|
|
|
solde_crediteur: 2000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ComptesData = [
|
|
{
|
|
numero_de_compte: '1001',
|
|
|
|
nom_de_compte: 'Caisse',
|
|
|
|
type_de_compte: 'Produit',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
numero_de_compte: '2001',
|
|
|
|
nom_de_compte: 'Fournisseurs',
|
|
|
|
type_de_compte: 'Actif',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
numero_de_compte: '3001',
|
|
|
|
nom_de_compte: 'Ventes',
|
|
|
|
type_de_compte: 'Produit',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
numero_de_compte: '4001',
|
|
|
|
nom_de_compte: 'Salaires',
|
|
|
|
type_de_compte: 'Produit',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const GrandlivresData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
date: new Date('2023-10-01T10:00:00Z'),
|
|
|
|
montant_debit: 500,
|
|
|
|
montant_credit: 0,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
date: new Date('2023-10-02T11:00:00Z'),
|
|
|
|
montant_debit: 0,
|
|
|
|
montant_credit: 500,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
date: new Date('2023-10-03T12:00:00Z'),
|
|
|
|
montant_debit: 1000,
|
|
|
|
montant_credit: 0,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
date: new Date('2023-10-04T13:00:00Z'),
|
|
|
|
montant_debit: 0,
|
|
|
|
montant_credit: 2000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const JournauxData = [
|
|
{
|
|
date: new Date('2023-10-01T10:00:00Z'),
|
|
|
|
numero_de_piece: 'J001',
|
|
|
|
libelle: 'Achat de fournitures',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
montant_debit: 500,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
montant_credit: 500,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
date: new Date('2023-10-02T11:00:00Z'),
|
|
|
|
numero_de_piece: 'J002',
|
|
|
|
libelle: 'Vente de produits',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
montant_debit: 1000,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
montant_credit: 1000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
date: new Date('2023-10-03T12:00:00Z'),
|
|
|
|
numero_de_piece: 'J003',
|
|
|
|
libelle: 'Paiement de salaires',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
montant_debit: 2000,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
montant_credit: 2000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
date: new Date('2023-10-04T13:00:00Z'),
|
|
|
|
numero_de_piece: 'J004',
|
|
|
|
libelle: 'Investissement en équipements',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
montant_debit: 3000,
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
montant_credit: 3000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const EntreprisesData = [
|
|
{
|
|
name: 'Archimedes',
|
|
},
|
|
|
|
{
|
|
name: 'Jean Piaget',
|
|
},
|
|
|
|
{
|
|
name: 'George Gaylord Simpson',
|
|
},
|
|
|
|
{
|
|
name: 'Theodosius Dobzhansky',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateUserWithEntreprise() {
|
|
const relatedEntreprise0 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const User0 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (User0?.setEntreprise) {
|
|
await User0.setEntreprise(relatedEntreprise0);
|
|
}
|
|
|
|
const relatedEntreprise1 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const User1 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (User1?.setEntreprise) {
|
|
await User1.setEntreprise(relatedEntreprise1);
|
|
}
|
|
|
|
const relatedEntreprise2 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const User2 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (User2?.setEntreprise) {
|
|
await User2.setEntreprise(relatedEntreprise2);
|
|
}
|
|
|
|
const relatedEntreprise3 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const User3 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (User3?.setEntreprise) {
|
|
await User3.setEntreprise(relatedEntreprise3);
|
|
}
|
|
}
|
|
|
|
async function associateBalanceWithCompte() {
|
|
const relatedCompte0 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Balance0 = await Balances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Balance0?.setCompte) {
|
|
await Balance0.setCompte(relatedCompte0);
|
|
}
|
|
|
|
const relatedCompte1 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Balance1 = await Balances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Balance1?.setCompte) {
|
|
await Balance1.setCompte(relatedCompte1);
|
|
}
|
|
|
|
const relatedCompte2 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Balance2 = await Balances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Balance2?.setCompte) {
|
|
await Balance2.setCompte(relatedCompte2);
|
|
}
|
|
|
|
const relatedCompte3 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Balance3 = await Balances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Balance3?.setCompte) {
|
|
await Balance3.setCompte(relatedCompte3);
|
|
}
|
|
}
|
|
|
|
async function associateBalanceWithEntreprise() {
|
|
const relatedEntreprise0 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Balance0 = await Balances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Balance0?.setEntreprise) {
|
|
await Balance0.setEntreprise(relatedEntreprise0);
|
|
}
|
|
|
|
const relatedEntreprise1 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Balance1 = await Balances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Balance1?.setEntreprise) {
|
|
await Balance1.setEntreprise(relatedEntreprise1);
|
|
}
|
|
|
|
const relatedEntreprise2 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Balance2 = await Balances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Balance2?.setEntreprise) {
|
|
await Balance2.setEntreprise(relatedEntreprise2);
|
|
}
|
|
|
|
const relatedEntreprise3 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Balance3 = await Balances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Balance3?.setEntreprise) {
|
|
await Balance3.setEntreprise(relatedEntreprise3);
|
|
}
|
|
}
|
|
|
|
async function associateCompteWithEntreprise() {
|
|
const relatedEntreprise0 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Compte0 = await Comptes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Compte0?.setEntreprise) {
|
|
await Compte0.setEntreprise(relatedEntreprise0);
|
|
}
|
|
|
|
const relatedEntreprise1 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Compte1 = await Comptes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Compte1?.setEntreprise) {
|
|
await Compte1.setEntreprise(relatedEntreprise1);
|
|
}
|
|
|
|
const relatedEntreprise2 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Compte2 = await Comptes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Compte2?.setEntreprise) {
|
|
await Compte2.setEntreprise(relatedEntreprise2);
|
|
}
|
|
|
|
const relatedEntreprise3 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Compte3 = await Comptes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Compte3?.setEntreprise) {
|
|
await Compte3.setEntreprise(relatedEntreprise3);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateCompteWithEntreprise() {
|
|
const relatedEntreprise0 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Compte0 = await Comptes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Compte0?.setEntreprise) {
|
|
await Compte0.setEntreprise(relatedEntreprise0);
|
|
}
|
|
|
|
const relatedEntreprise1 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Compte1 = await Comptes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Compte1?.setEntreprise) {
|
|
await Compte1.setEntreprise(relatedEntreprise1);
|
|
}
|
|
|
|
const relatedEntreprise2 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Compte2 = await Comptes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Compte2?.setEntreprise) {
|
|
await Compte2.setEntreprise(relatedEntreprise2);
|
|
}
|
|
|
|
const relatedEntreprise3 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Compte3 = await Comptes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Compte3?.setEntreprise) {
|
|
await Compte3.setEntreprise(relatedEntreprise3);
|
|
}
|
|
}
|
|
|
|
async function associateGrandlivreWithCompte() {
|
|
const relatedCompte0 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Grandlivre0 = await Grandlivres.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Grandlivre0?.setCompte) {
|
|
await Grandlivre0.setCompte(relatedCompte0);
|
|
}
|
|
|
|
const relatedCompte1 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Grandlivre1 = await Grandlivres.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Grandlivre1?.setCompte) {
|
|
await Grandlivre1.setCompte(relatedCompte1);
|
|
}
|
|
|
|
const relatedCompte2 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Grandlivre2 = await Grandlivres.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Grandlivre2?.setCompte) {
|
|
await Grandlivre2.setCompte(relatedCompte2);
|
|
}
|
|
|
|
const relatedCompte3 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Grandlivre3 = await Grandlivres.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Grandlivre3?.setCompte) {
|
|
await Grandlivre3.setCompte(relatedCompte3);
|
|
}
|
|
}
|
|
|
|
async function associateGrandlivreWithEntreprise() {
|
|
const relatedEntreprise0 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Grandlivre0 = await Grandlivres.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Grandlivre0?.setEntreprise) {
|
|
await Grandlivre0.setEntreprise(relatedEntreprise0);
|
|
}
|
|
|
|
const relatedEntreprise1 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Grandlivre1 = await Grandlivres.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Grandlivre1?.setEntreprise) {
|
|
await Grandlivre1.setEntreprise(relatedEntreprise1);
|
|
}
|
|
|
|
const relatedEntreprise2 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Grandlivre2 = await Grandlivres.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Grandlivre2?.setEntreprise) {
|
|
await Grandlivre2.setEntreprise(relatedEntreprise2);
|
|
}
|
|
|
|
const relatedEntreprise3 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Grandlivre3 = await Grandlivres.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Grandlivre3?.setEntreprise) {
|
|
await Grandlivre3.setEntreprise(relatedEntreprise3);
|
|
}
|
|
}
|
|
|
|
async function associateJournauxWithCompte_debit() {
|
|
const relatedCompte_debit0 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Journaux0 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Journaux0?.setCompte_debit) {
|
|
await Journaux0.setCompte_debit(relatedCompte_debit0);
|
|
}
|
|
|
|
const relatedCompte_debit1 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Journaux1 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Journaux1?.setCompte_debit) {
|
|
await Journaux1.setCompte_debit(relatedCompte_debit1);
|
|
}
|
|
|
|
const relatedCompte_debit2 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Journaux2 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Journaux2?.setCompte_debit) {
|
|
await Journaux2.setCompte_debit(relatedCompte_debit2);
|
|
}
|
|
|
|
const relatedCompte_debit3 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Journaux3 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Journaux3?.setCompte_debit) {
|
|
await Journaux3.setCompte_debit(relatedCompte_debit3);
|
|
}
|
|
}
|
|
|
|
async function associateJournauxWithCompte_credit() {
|
|
const relatedCompte_credit0 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Journaux0 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Journaux0?.setCompte_credit) {
|
|
await Journaux0.setCompte_credit(relatedCompte_credit0);
|
|
}
|
|
|
|
const relatedCompte_credit1 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Journaux1 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Journaux1?.setCompte_credit) {
|
|
await Journaux1.setCompte_credit(relatedCompte_credit1);
|
|
}
|
|
|
|
const relatedCompte_credit2 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Journaux2 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Journaux2?.setCompte_credit) {
|
|
await Journaux2.setCompte_credit(relatedCompte_credit2);
|
|
}
|
|
|
|
const relatedCompte_credit3 = await Comptes.findOne({
|
|
offset: Math.floor(Math.random() * (await Comptes.count())),
|
|
});
|
|
const Journaux3 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Journaux3?.setCompte_credit) {
|
|
await Journaux3.setCompte_credit(relatedCompte_credit3);
|
|
}
|
|
}
|
|
|
|
async function associateJournauxWithEntreprise() {
|
|
const relatedEntreprise0 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Journaux0 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Journaux0?.setEntreprise) {
|
|
await Journaux0.setEntreprise(relatedEntreprise0);
|
|
}
|
|
|
|
const relatedEntreprise1 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Journaux1 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Journaux1?.setEntreprise) {
|
|
await Journaux1.setEntreprise(relatedEntreprise1);
|
|
}
|
|
|
|
const relatedEntreprise2 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Journaux2 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Journaux2?.setEntreprise) {
|
|
await Journaux2.setEntreprise(relatedEntreprise2);
|
|
}
|
|
|
|
const relatedEntreprise3 = await Entreprises.findOne({
|
|
offset: Math.floor(Math.random() * (await Entreprises.count())),
|
|
});
|
|
const Journaux3 = await Journaux.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Journaux3?.setEntreprise) {
|
|
await Journaux3.setEntreprise(relatedEntreprise3);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Balances.bulkCreate(BalancesData);
|
|
|
|
await Comptes.bulkCreate(ComptesData);
|
|
|
|
await Grandlivres.bulkCreate(GrandlivresData);
|
|
|
|
await Journaux.bulkCreate(JournauxData);
|
|
|
|
await Entreprises.bulkCreate(EntreprisesData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithEntreprise(),
|
|
|
|
await associateBalanceWithCompte(),
|
|
|
|
await associateBalanceWithEntreprise(),
|
|
|
|
await associateCompteWithEntreprise(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateCompteWithEntreprise(),
|
|
|
|
await associateGrandlivreWithCompte(),
|
|
|
|
await associateGrandlivreWithEntreprise(),
|
|
|
|
await associateJournauxWithCompte_debit(),
|
|
|
|
await associateJournauxWithCompte_credit(),
|
|
|
|
await associateJournauxWithEntreprise(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('balances', null, {});
|
|
|
|
await queryInterface.bulkDelete('comptes', null, {});
|
|
|
|
await queryInterface.bulkDelete('grandlivres', null, {});
|
|
|
|
await queryInterface.bulkDelete('journaux', null, {});
|
|
|
|
await queryInterface.bulkDelete('entreprises', null, {});
|
|
},
|
|
};
|