-
Notifications
You must be signed in to change notification settings - Fork 0
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
Remove left over references in geometry columns #139
Merged
margrietpalm
merged 25 commits into
margriet_schema_300_leftovers
from
margriet_107_left_over_references_in_geometry_columns
Nov 26, 2024
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
37b2e98
Implement cleaning up schematisation
margrietpalm 0c03d1f
update changes
margrietpalm ba00a1b
Move cleaning to seperate function
margrietpalm 416b0f5
Remove columns referencing v2 in geometry_column
margrietpalm 1e91d6e
Update changes
margrietpalm e38d72c
Try to remove tables iwth DropGeoTable
margrietpalm 41f3007
Replace plain drop table with DropGeoTable in migration 0223
margrietpalm 5bf4446
Replace plain drop table with DropGeoTable in migration 0224
margrietpalm 31856f5
Replace plain drop table with DropGeoTable in migration 0225
margrietpalm 5908b72
Replace plain drop table with DropGeoTable in migration 0226
margrietpalm 6a02b55
Replace plain drop table with DropTable in migration 0228 and limit r…
margrietpalm 92a48fb
Move code for dropping tables to single file to reduce duplications
margrietpalm 32e57de
Use spatialite RenameTable to rename table with geometry columns
margrietpalm 6b64d12
Enable removing stuff and clean up triggers
margrietpalm 29ee655
Merge branch 'margriet_schema_300_leftovers' into margriet_107_left_o…
margrietpalm c27aaa7
Modify drop_geo_table to work with DropGeoTable instead of DropTable …
margrietpalm c5b6502
Merge branch 'margriet_107_left_over_references_in_geometry_columns' …
margrietpalm 2d76c90
Modify table renaming to work with spatialite 4 and 5
margrietpalm 01fd353
Remove python 3.8 test
margrietpalm 5b1959f
Move to ubuntu 22.04 for python 3.9 test
margrietpalm 2abe679
Merge branch 'margriet_schema_300_leftovers' into margriet_107_left_o…
margrietpalm 5913495
Merge branch 'margriet_schema_300_leftovers' into margriet_107_left_o…
margrietpalm 64d21c5
Make linter happy
margrietpalm b1577ba
Use DropTable instead of DropGeoTable
margrietpalm e1c3cab
Remove commented breakpoint
margrietpalm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,32 @@ | ||
from typing import List | ||
|
||
import sqlalchemy as sa | ||
|
||
|
||
def drop_geo_table(op, table_name: str): | ||
""" | ||
|
||
Safely drop table, taking into account geometry columns | ||
|
||
Parameters: | ||
op : object | ||
An object representing the database operation. | ||
table_name : str | ||
The name of the table to be dropped. | ||
""" | ||
op.execute(sa.text(f"SELECT DropTable(NULL, '{table_name}');")) | ||
|
||
|
||
def drop_conflicting(op, new_tables: List[str]): | ||
""" | ||
Drop tables from database that conflict with new tables | ||
|
||
Parameters: | ||
op: The SQLAlchemy operation context to interact with the database. | ||
new_tables: A list of new table names to be checked for conflicts with existing tables. | ||
""" | ||
connection = op.get_bind() | ||
existing_tables = [item[0] for item in connection.execute( | ||
sa.text("SELECT name FROM sqlite_master WHERE type='table';")).fetchall()] | ||
for table_name in set(existing_tables).intersection(new_tables): | ||
drop_geo_table(op, table_name) | ||
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this is the right place to put this. I may move other functions here to prevent changing the same functionality multiple times in migrations 222 to 228.