89 lines
2.4 KiB
JavaScript
89 lines
2.4 KiB
JavaScript
const db = require('mantra-db-models');
|
|
const prompt = require("prompt")
|
|
|
|
db.init().then(() => {
|
|
// We could probably run the things in the seeders...
|
|
db.Language.findAll()
|
|
.then(languages => {
|
|
if (languages.length == 0) {
|
|
// TODO: Create languages
|
|
return db.Language.bulkCreate([
|
|
{
|
|
id: "en",
|
|
name: "English",
|
|
displayName: "English",
|
|
},
|
|
{
|
|
id: "st",
|
|
name: "Sesotho",
|
|
displayName: "Sesotho",
|
|
},
|
|
{
|
|
id: "zu",
|
|
name: "Isizulu",
|
|
displayName: "Isizulu",
|
|
}
|
|
])
|
|
} else {
|
|
return languages
|
|
}
|
|
}).then(languages => {
|
|
return db.Continent.findAll()
|
|
}).then(continents => {
|
|
if (continents.length == 0) {
|
|
return db.Continent.bulkCreate([
|
|
{
|
|
id: "afr",
|
|
name: "Africa"
|
|
}
|
|
])
|
|
} else {
|
|
return continents
|
|
}
|
|
}).then(continents => {
|
|
return db.Country.findAll()
|
|
}).then(countries => {
|
|
if (countries.length == 0) {
|
|
return db.Country.bulkCreate([
|
|
{
|
|
id: "int",
|
|
name: "International"
|
|
},
|
|
{
|
|
id: "zaf",
|
|
name: "South Africa"
|
|
}
|
|
])
|
|
} else {
|
|
return countries
|
|
}
|
|
}).then(countries => {
|
|
return db.Dialect.findAll()
|
|
}).then(dialects => {
|
|
if (dialects.length == 0) {
|
|
// TODO: Create dialects
|
|
return db.Dialect.bulkCreate([
|
|
{
|
|
name: "English",
|
|
countryId: "int",
|
|
languageId: "en"
|
|
},
|
|
{
|
|
name: "Sesotho",
|
|
countryId: "zaf",
|
|
languageId: "st"
|
|
},
|
|
{
|
|
name: "Zulu",
|
|
countryId: "zaf",
|
|
languageId: "zu"
|
|
}
|
|
])
|
|
} else {
|
|
return dialects
|
|
}
|
|
}).catch(error => {
|
|
console.error("Error: ", error)
|
|
})
|
|
})
|