-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🎨 run database population in transaction #7448
🎨 run database population in transaction #7448
Conversation
FYI: right now i am writing down a migration spec. I will update add the reference to the Github issue later. |
Note: merge into |
transaction.rollback(); | ||
}); | ||
}).catch(function populateDatabaseError() { | ||
reject(); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
refs TryGhost#6574, refs TryGhost#7432 - create transaction for creating tables - if an error occurs or a container get's destroyed before population finishes, transaction is rolled back
eac4d78
to
3ecce35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is some simplification that can be done here.
}); | ||
}).catch(function populateDatabaseError(err) { | ||
reject(err); | ||
}); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
return new Promise.resolve(); | ||
}); | ||
|
||
transactionStub = sandbox.stub(db.knex, 'transaction', function (transactionStart) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -56,7 +56,7 @@ createOwner = function createOwner(logger, modelOptions) { | |||
password: coreUtils.uid(50) | |||
}; | |||
|
|||
return models.Role.findOne({name: 'Owner'}).then(function (ownerRole) { | |||
return models.Role.findOne({name: 'Owner'}, modelOptions).then(function (ownerRole) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
See second commit, i kept it so you can look at it 👍 |
This looks 100% awesome to me 👍 |
Have cherrypicked this directly onto the lts branch as it is a clean merge. |
* 🎨 run database population in transaction refs TryGhost#6574, refs TryGhost#7432 - create transaction for creating tables - if an error occurs or a container get's destroyed before population finishes, transaction is rolled back * 🎨 simplify transaction creation and test
* 🎨 run database population in transaction refs TryGhost#6574, refs TryGhost#7432 - create transaction for creating tables - if an error occurs or a container get's destroyed before population finishes, transaction is rolled back * 🎨 simplify transaction creation and test
* 🎨 run database population in transaction refs TryGhost#6574, refs TryGhost#7432 - create transaction for creating tables - if an error occurs or a container get's destroyed before population finishes, transaction is rolled back * 🎨 simplify transaction creation and test
refs #6574, refs #7432
Populate database in a transaction.
We had issues in the past, that if a Ghost container get's destroyed before the population could finish, the database was left in a corrupt state.