Skip to content
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

Roles: db migration to create constraints #7689

Merged
merged 11 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ ifneq ($(PR), false)
endif

initdb:
docker-compose run --rm web psql -h db -d postgres -U postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname ='warehouse';"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disconnects any other sessions to make make initdb run regardless of if make serve containers are accessing the db.

docker-compose run --rm web psql -h db -d postgres -U postgres -c "DROP DATABASE IF EXISTS warehouse"
docker-compose run --rm web psql -h db -d postgres -U postgres -c "CREATE DATABASE warehouse ENCODING 'UTF8'"
xz -d -f -k dev/$(DB).sql.xz --stdout | docker-compose run --rm web psql -h db -d warehouse -U postgres -v ON_ERROR_STOP=1 -1 -f -
Expand Down
1 change: 1 addition & 0 deletions tests/common/db/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def _create(cls, *args, **kwargs):
r = super()._create(*args, **kwargs)
session = cls._meta.sqlalchemy_session
session.flush()
session.expire_all()
return r


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/admin/views/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,13 @@ def test_invalid_key_query(self, db_request):
reverse=True,
)
db_request.matchdict["project_name"] = project.normalized_name
db_request.GET["q"] = "user:{}".format(journals[3].submitted_by)
db_request.GET["q"] = "user:username"
result = views.journals_list(project, db_request)

assert result == {
"journals": journals[:25],
"project": project,
"query": "user:{}".format(journals[3].submitted_by),
"query": "user:username",
}

def test_basic_query(self, db_request):
Expand Down
16 changes: 0 additions & 16 deletions tests/unit/legacy/api/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ def test_no_files_with_serial(self, db_request):
user = UserFactory.create()
je = JournalEntryFactory.create(name=project.name, submitted_by=user)

# Make sure that we get any changes made since the JournalEntry was
# saved.
db_request.db.refresh(project)

assert simple.simple_detail(project, db_request) == {
"project": project,
"files": [],
Expand All @@ -118,10 +114,6 @@ def test_with_files_no_serial(self, db_request):
user = UserFactory.create()
JournalEntryFactory.create(submitted_by=user)

# Make sure that we get any changes made since the JournalEntry was
# saved.
db_request.db.refresh(project)

assert simple.simple_detail(project, db_request) == {
"project": project,
"files": files,
Expand All @@ -143,10 +135,6 @@ def test_with_files_with_serial(self, db_request):
user = UserFactory.create()
je = JournalEntryFactory.create(name=project.name, submitted_by=user)

# Make sure that we get any changes made since the JournalEntry was
# saved.
db_request.db.refresh(project)

assert simple.simple_detail(project, db_request) == {
"project": project,
"files": files,
Expand Down Expand Up @@ -201,10 +189,6 @@ def test_with_files_with_version_multi_digit(self, db_request):
user = UserFactory.create()
je = JournalEntryFactory.create(name=project.name, submitted_by=user)

# Make sure that we get any changes made since the JournalEntry was
# saved.
db_request.db.refresh(project)

assert simple.simple_detail(project, db_request) == {
"project": project,
"files": files,
Expand Down
Loading