-
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.
New feature: Rollback the last migration
- Loading branch information
1 parent
1ecf3b0
commit 6c7edda
Showing
10 changed files
with
180 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ | |
__all__ = [ | ||
"Migration" | ||
] | ||
__version__ = "0.5.1" | ||
__version__ = "0.5.2" |
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
36 changes: 36 additions & 0 deletions
36
tests/unit/migrations/2024_01_04_120000_create_another_table_example.py
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 @@ | ||
from google.cloud import bigquery | ||
from src.bigquery_migrations.migration import Migration | ||
|
||
class CreateAnotherTableExample(Migration): | ||
""" | ||
See: | ||
https://github.com/googleapis/python-bigquery/tree/main/samples | ||
""" | ||
|
||
def up(self): | ||
# TODO: Set table_id to the ID of the table to create. | ||
# table_id = "your_project.your_dataset.example_table" | ||
|
||
# TODO: Define table schema | ||
''' | ||
schema = [ | ||
bigquery.SchemaField("id", "INTEGER", mode="REQUIRED"), | ||
bigquery.SchemaField("name", "STRING", mode="REQUIRED"), | ||
bigquery.SchemaField("created_at", "TIMESTAMP", mode="NULLABLE"), | ||
] | ||
''' | ||
|
||
# table = bigquery.Table(table_id, schema=schema) | ||
# table = self.client.create_table(table) | ||
class_name = self.__class__.__name__ | ||
print(f"Class: {class_name}, Method: up") | ||
|
||
def down(self): | ||
# TODO: Set table_id to the ID of the table to fetch. | ||
# table_id = "your_project.your_dataset.example_table" | ||
|
||
# If the table does not exist, delete_table raises | ||
# google.api_core.exceptions.NotFound unless not_found_ok is True. | ||
# self.client.delete_table(table_id, not_found_ok=True) | ||
class_name = self.__class__.__name__ | ||
print(f"Class: {class_name}, Method: down") |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"last_migration": null, "timestamp": "2024-12-18T12:34:49.269255+00:00"} | ||
{"last_migration": null, "timestamp": "2024-12-23T16:12:39.282297+00:00"} |
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.