This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
67 additions
and
46 deletions.
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
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
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,36 @@ | ||
# Run migrations for the first time. | ||
resource "terraform_data" "run_migrations" { | ||
depends_on = [var.main_database] | ||
provisioner "local-exec" { | ||
# Relative to DSS terraform project root. | ||
command = file("modules/migrations/run-migrations.sh") | ||
environment = { | ||
DATABASE_URL = var.db_conn_str_auth_proxy, | ||
DB_CONNECTION_NAME = var.db_connection_name, | ||
CREDENTIALS_FILE = var.credentials_file | ||
} | ||
} | ||
} | ||
|
||
# Re-run migrations after database initialization. | ||
# | ||
# Tracked as a separate resource so that followup migrations can be run | ||
# by simply destroying and re-applying this resource. The destroy/re-apply | ||
# approach doesn't work for the initial migrations resource since other | ||
# resources depend on initial migrations and they would have to be deleted | ||
# too if initial migrations were, hence this duplicate. | ||
# | ||
# Upon database creation, migrations will be run twice, but this is not a | ||
# problem because diesel only runs new migrations upon subsequent calls to the | ||
# same database. | ||
resource "terraform_data" "re_run_migrations" { | ||
depends_on = [terraform_data.run_migrations] | ||
provisioner "local-exec" { | ||
command = file("modules/migrations/run-migrations.sh") | ||
environment = { | ||
DATABASE_URL = var.db_conn_str_auth_proxy, | ||
DB_CONNECTION_NAME = var.db_connection_name, | ||
CREDENTIALS_FILE = var.credentials_file | ||
} | ||
} | ||
} |
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,3 @@ | ||
output "migrations_complete" { | ||
value = terraform_data.run_migrations | ||
} |
File renamed without changes.
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,7 @@ | ||
variable "db_conn_str_auth_proxy" {} | ||
|
||
variable "db_connection_name" {} | ||
|
||
variable "main_database" {} | ||
|
||
variable "credentials_file" {} |
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
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