mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 02:51:57 +02:00
Merge pull request #1999 from overleaf/spd-migrations
Add database migrations using 'east' GitOrigin-RevId: da067292e9db1fad050545858bc7cc39245d3395
This commit is contained in:
committed by
sharelatex
parent
2eb1f510c1
commit
11ce07ec50
28
services/web/scripts/example/script_for_migration.js
Normal file
28
services/web/scripts/example/script_for_migration.js
Normal file
@@ -0,0 +1,28 @@
|
||||
/* subscription.freeTrialExpiresAt
|
||||
* Example script for a migration:
|
||||
*
|
||||
* This script demonstrates how to write a script that is runnable either via
|
||||
* the CLI, or via a migration. The related migration is `script_example`
|
||||
* in the migrations directory.
|
||||
*/
|
||||
|
||||
const { User } = require('../../app/src/models/User')
|
||||
require('colors')
|
||||
|
||||
const runScript = async () => {
|
||||
const user = await User.findOne({}, { first_name: 1 }).exec()
|
||||
const name = user ? user.first_name : 'World'
|
||||
console.log(`Hello ${name}!`.rainbow.underline.bold)
|
||||
}
|
||||
|
||||
if (!module.parent) {
|
||||
// we are in the root module, which means that we're running as a script
|
||||
runScript()
|
||||
.then(() => process.exit())
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = runScript
|
||||
Reference in New Issue
Block a user