-
Notifications
You must be signed in to change notification settings - Fork 635
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
Preseed all the databases #8468
Merged
rtibbles
merged 8 commits into
learningequality:develop
from
rtibbles:preseed_all_the_dbs
Sep 27, 2021
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1df3f26
Preseed all SQLite db files.
rtibbles 1468674
Add no-input option to deprovision.
rtibbles e2259bf
Add db file preseeding for all sqlite db files.
rtibbles 27e3057
Don't make it easy to skip confirmation for deprovision.
rtibbles 1397a65
Don't error when path doesn't exist.
rtibbles 39bd68f
Generate target path properly.
rtibbles e2e0852
Preseed DBs in dist command.
rtibbles 1433765
Add kolibri to python path.
rtibbles File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import shutil | ||
import tempfile | ||
|
||
temphome = tempfile.mkdtemp() | ||
os.environ["KOLIBRI_HOME"] = temphome | ||
|
||
from kolibri.main import initialize # noqa E402 | ||
from kolibri.deployment.default.sqlite_db_names import ( # noqa E402 | ||
ADDITIONAL_SQLITE_DATABASES, | ||
) | ||
from django.core.management import call_command # noqa E402 | ||
|
||
move_to = os.path.join(os.path.dirname(__file__), "..", "kolibri", "dist", "home") | ||
shutil.rmtree(move_to, ignore_errors=True) | ||
os.mkdir(move_to) | ||
|
||
print("Generating preseeded home data in {}".format(temphome)) | ||
|
||
initialize() | ||
call_command( | ||
"deprovision", "--destroy-all-user-data", "--permanent-irrevocable-data-loss" | ||
) | ||
|
||
shutil.move(os.path.join(temphome, "db.sqlite3"), move_to) | ||
|
||
for db_name in ADDITIONAL_SQLITE_DATABASES: | ||
shutil.move(os.path.join(temphome, "{}.sqlite3".format(db_name)), move_to) | ||
|
||
print("Moved all preseeded home data to {}".format(move_to)) | ||
|
||
shutil.rmtree(temphome) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We had previously made the explicit choice not to make it that easy to deprovision without warnings, given how destructive it is.
If a one-liner is really needed, we've suggested
yes yes|kolibri manage deprovision
in the past. I guess that doesn't work on Windows, though.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.
Ah, I see it's for the purposes of
call_command
, though -- I wonder about using a nonstandard name like--accept-data-loss
or something to make it a bit harder to do accidentally.I'm probably being paranoid. Except if there's anything we've learned from what users do.....
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.
Yeah, I only added it because of the python invocation, happy to make it something ridiculous!
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.
Throw some unicode for a few different languages in there and we should be good, then!