full
This commit is contained in:
28
scripts/seedGeoData.js
Normal file
28
scripts/seedGeoData.js
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Manual/CI trigger for the same geo seed logic that also runs automatically
|
||||
* on every backend boot (utils/ensureGeoData.js, wired in boot/mongo.js) —
|
||||
* kept as a single shared implementation so the two paths never drift.
|
||||
*
|
||||
* Run from modstagram-back:
|
||||
* node scripts/seedGeoData.js
|
||||
*/
|
||||
require('dotenv').config()
|
||||
const mongoose = require('mongoose')
|
||||
const { ensureGeoData } = require('../utils/ensureGeoData')
|
||||
|
||||
async function main() {
|
||||
const uri = process.env.DATABASE_URL
|
||||
if (!uri) {
|
||||
console.error('DATABASE_URL is required (check .env)')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
await mongoose.connect(uri, { authSource: 'admin' })
|
||||
await ensureGeoData(true)
|
||||
await mongoose.disconnect()
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user