Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
a6750812
Commit
a6750812
authored
Jan 12, 2016
by
Jesse Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add comments to the bok-choy DB reset script
parent
12e8a3ea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletions
+21
-1
scripts/reset-test-db.sh
+21
-1
No files found.
scripts/reset-test-db.sh
View file @
a6750812
...
@@ -28,34 +28,54 @@ DB_CACHE_DIR="common/test/db_cache"
...
@@ -28,34 +28,54 @@ DB_CACHE_DIR="common/test/db_cache"
echo
"CREATE DATABASE IF NOT EXISTS edxtest;"
| mysql
-u
root
echo
"CREATE DATABASE IF NOT EXISTS edxtest;"
| mysql
-u
root
# Clear out the test database
# Clear out the test database
#
# We are using the django-extensions's reset_db command which uses "DROP DATABASE" and
# "CREATE DATABASE" in case the tests are being run in an environment (e.g. devstack
# or a jenkins worker environment) that already ran tests on another commit that had
# different migrations that created, dropped, or altered tables.
#
# Note that as a side effect, this might render the --serversonly / --testsonly
# paver options useless or broken.
echo
"Issuing a reset_db command to the bok_choy MySQL database."
./manage.py lms
--settings
bok_choy reset_db
--traceback
--noinput
./manage.py lms
--settings
bok_choy reset_db
--traceback
--noinput
# If there are cached database schemas/data, load them
# If there are cached database schemas/data, load them
if
[[
-f
$DB_CACHE_DIR
/bok_choy_schema.sql
&&
-f
$DB_CACHE_DIR
/bok_choy_migrations_data.sql
&&
-f
$DB_CACHE_DIR
/bok_choy_data.json
]]
;
then
if
[[
-f
$DB_CACHE_DIR
/bok_choy_schema.sql
&&
-f
$DB_CACHE_DIR
/bok_choy_migrations_data.sql
&&
-f
$DB_CACHE_DIR
/bok_choy_data.json
]]
;
then
echo
"Found the bok_choy DB cache files. Loading them into the database..."
# Load the schema, then the data (including the migration history)
# Load the schema, then the data (including the migration history)
echo
"Loading the schema from the filesystem into the MySQL DB."
mysql
-u
root edxtest <
$DB_CACHE_DIR
/bok_choy_schema.sql
mysql
-u
root edxtest <
$DB_CACHE_DIR
/bok_choy_schema.sql
echo
"Loading the migration data from the filesystem into the MySQL DB."
mysql
-u
root edxtest <
$DB_CACHE_DIR
/bok_choy_migrations_data.sql
mysql
-u
root edxtest <
$DB_CACHE_DIR
/bok_choy_migrations_data.sql
echo
"Loading the fixture data from the filesystem into the MySQL DB."
./manage.py lms
--settings
bok_choy loaddata
$DB_CACHE_DIR
/bok_choy_data.json
./manage.py lms
--settings
bok_choy loaddata
$DB_CACHE_DIR
/bok_choy_data.json
# Re-run migrations to ensure we are up-to-date
# Re-run migrations to ensure we are up-to-date
echo
"Running the lms migrations on the bok_choy DB."
./manage.py lms
--settings
bok_choy migrate
--traceback
--noinput
./manage.py lms
--settings
bok_choy migrate
--traceback
--noinput
echo
"Running the cms migrations on the bok_choy DB."
./manage.py cms
--settings
bok_choy migrate
--traceback
--noinput
./manage.py cms
--settings
bok_choy migrate
--traceback
--noinput
# Otherwise, update the test database and update the cache
# Otherwise, update the test database and update the cache
else
else
echo
"Did not find a bok_choy DB cache. Creating a new one from scratch."
# Clean the cache directory
# Clean the cache directory
rm
-rf
$DB_CACHE_DIR
&&
mkdir
-p
$DB_CACHE_DIR
rm
-rf
$DB_CACHE_DIR
&&
mkdir
-p
$DB_CACHE_DIR
# Re-run migrations on the test database
# Re-run migrations on the test database
echo
"Issuing a migrate command to the bok_choy MySQL database for the lms django apps."
./manage.py lms
--settings
bok_choy migrate
--traceback
--noinput
./manage.py lms
--settings
bok_choy migrate
--traceback
--noinput
echo
"Issuing a migrate command to the bok_choy MySQL database for the cms django apps."
./manage.py cms
--settings
bok_choy migrate
--traceback
--noinput
./manage.py cms
--settings
bok_choy migrate
--traceback
--noinput
# Dump the schema and data to the cache
# Dump the schema and data to the cache
echo
"Using the dumpdata command to save the fixture data to the filesystem."
./manage.py lms
--settings
bok_choy dumpdata
>
$DB_CACHE_DIR
/bok_choy_data.json
./manage.py lms
--settings
bok_choy dumpdata
>
$DB_CACHE_DIR
/bok_choy_data.json
# dump_data does not dump the django_migrations table so we do it separately.
# dump_data does not dump the django_migrations table so we do it separately.
echo
"Saving the django_migrations table of the bok_choy DB to the filesystem."
mysqldump
-u
root
--no-create-info
edxtest django_migrations
>
$DB_CACHE_DIR
/bok_choy_migrations_data.sql
mysqldump
-u
root
--no-create-info
edxtest django_migrations
>
$DB_CACHE_DIR
/bok_choy_migrations_data.sql
echo
"Saving the schema of the bok_choy DB to the filesystem."
mysqldump
-u
root
--no-data
--skip-comments
--skip-dump-date
edxtest
>
$DB_CACHE_DIR
/bok_choy_schema.sql
mysqldump
-u
root
--no-data
--skip-comments
--skip-dump-date
edxtest
>
$DB_CACHE_DIR
/bok_choy_schema.sql
fi
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment