-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding liquibase schema management. (#133)
- Loading branch information
Showing
14 changed files
with
364 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2023 Google LLC All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
changeLogFile: /liquibase/changelog.yaml | ||
url: jdbc:cloudspanner:/projects/${project_id}/instances/${instance_id}/databases/${database_id} | ||
logLevel: 0 | ||
liquibase.hub.mode=off | ||
liquibase.includeSystemClasspath:true |
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,20 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https:#www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM liquibase/liquibase:4.17 | ||
COPY liquibase.properties /liquibase/liquibase.properties | ||
COPY changelog.yaml /liquibase/changelog.yaml | ||
COPY lib/liquibase-spanner-*.jar /liquibase/lib/. | ||
|
||
CMD ["liquibase", "update", "--defaultsFile=/liquibase/liquibase.properties"] |
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,86 @@ | ||
# Copyright 2023 Google LLC All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
databaseChangeLog: | ||
- preConditions: | ||
onFail: HALT | ||
onError: HALT | ||
|
||
# CREATE TABLE players ( | ||
# player_google_id STRING(MAX) NOT NULL, | ||
# player_name STRING(64) NOT NULL, | ||
# profile_image STRING(MAX) NOT NULL, | ||
# region STRING(10) NOT NULL, | ||
# skill_level int64 NOT NULL, | ||
# tier STRING(1) NOT NULL, | ||
# stats JSON, | ||
# ) PRIMARY KEY(player_google_id); | ||
|
||
- changeSet: | ||
id: create-players-table | ||
author: dtest | ||
changes: | ||
- createTable: | ||
tableName: players | ||
columns: | ||
- column: | ||
name: player_google_id | ||
type: STRING(MAX) | ||
constraints: | ||
primaryKey: true | ||
- column: | ||
name: player_name | ||
type: STRING(MAX) | ||
constraints: | ||
nullable: false | ||
- column: | ||
name: profile_image | ||
type: STRING(MAX) | ||
constraints: | ||
nullable: false | ||
- column: | ||
name: region | ||
type: STRING(10) | ||
constraints: | ||
nullable: false | ||
- column: | ||
name: skill_level | ||
type: BIGINT | ||
constraints: | ||
nullable: false | ||
- column: | ||
name: tier | ||
type: STRING(1) | ||
constraints: | ||
nullable: false | ||
- column: | ||
name: stats | ||
type: JSON | ||
|
||
# CREATE TABLE game_assets | ||
# ( | ||
# asset_uuid STRING(36) NOT NULL, | ||
# asset_name STRING(MAX) NOT NULL, | ||
# available_time TIMESTAMP NOT NULL | ||
# )PRIMARY KEY (asset_uuid); | ||
|
||
# CREATE TABLE player_assets | ||
# ( | ||
# player_asset_uuid STRING(36) NOT NULL, | ||
# player_google_id STRING(MAX) NOT NULL, | ||
# asset_uuid STRING(36) NOT NULL, | ||
# acquire_time TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP()), | ||
# FOREIGN KEY (asset_uuid) REFERENCES game_assets (asset_uuid) | ||
# ) PRIMARY KEY (player_google_id, player_asset_uuid), | ||
# INTERLEAVE IN PARENT players ON DELETE CASCADE; |
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,60 @@ | ||
# Copyright 2023 Google LLC All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
serviceAccount: projects/${PROJECT_ID}/serviceAccounts/cloudbuild-cicd@${PROJECT_ID}.iam.gserviceaccount.com | ||
steps: | ||
|
||
# | ||
# Building of schema image | ||
# | ||
|
||
- name: gcr.io/cloud-builders/docker | ||
id: schema image build | ||
args: ["build", ".", "-t", "${_SCHEMA_IMAGE}"] | ||
|
||
- name: gcr.io/cloud-builders/docker | ||
id: schema image push | ||
args: ["push", "${_SCHEMA_IMAGE}"] | ||
|
||
# | ||
# Create schema job | ||
# | ||
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk:slim" | ||
id: schema migrate create | ||
entrypoint: gcloud | ||
args: ["beta", "run", "jobs", "create", "${_RUN_JOB}", | ||
"--image", "${_SCHEMA_IMAGE}", "--region", "${_REGION}"] | ||
|
||
# | ||
# Running schema migration | ||
# | ||
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk:slim" | ||
id: schema migrate execute | ||
entrypoint: gcloud | ||
args: ["beta", "run", "jobs", "execute", "${_RUN_JOB}", | ||
"--region", "${_REGION}", "--wait"] | ||
|
||
# artifacts: | ||
# images: | ||
# - ${_REGISTRY}/schema | ||
substitutions: | ||
_SCHEMA_IMAGE: ${_REGISTRY}/schema:${BUILD_ID} | ||
_RUN_JOB: migrate-database-${BUILD_ID} | ||
_REGISTRY: us-docker.pkg.dev/${PROJECT_ID}/global-game-images | ||
_REGION: us-central1 | ||
|
||
options: | ||
dynamic_substitutions: true | ||
machineType: E2_HIGHCPU_8 | ||
logging: CLOUD_LOGGING_ONLY |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.