Skip to content

Commit

Permalink
Merge pull request #3198 from prisma/fix/migrate-prevent-deleting-pos…
Browse files Browse the repository at this point in the history
…tgis-columns

fix: prevent deletion of 'raster_columns' and 'raster_overviews' PostGIS columns in prisma migrate
  • Loading branch information
jkomyno committed Sep 17, 2022
2 parents 4124c5c + 32bdca5 commit fb56bfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Expand Up @@ -22,6 +22,9 @@ static POSTGIS_TABLES_OR_VIEWS: Lazy<RegexSet> = Lazy::new(|| {
"(?i)^spatial_ref_sys$",
"(?i)^geometry_columns$",
"(?i)^geography_columns$",
// See §11.2 in: https://postgis.net/docs/using_raster_dataman.html
"(?i)^raster_columns$",
"(?i)^raster_overviews$",
])
.unwrap()
});
Expand Down
Expand Up @@ -71,6 +71,8 @@ fn existing_postgis_tables_must_not_be_migrated(api: TestApi) {
/* The capitalized Geometry is intentional here, because we want the matching to be case-insensitive. */
CREATE TABLE IF NOT EXISTS "Geometry_columns" ( id SERIAL PRIMARY KEY );
CREATE TABLE IF NOT EXISTS "geography_columns" ( id SERIAL PRIMARY KEY );
CREATE TABLE IF NOT EXISTS "raster_columns" ( id SERIAL PRIMARY KEY );
CREATE TABLE IF NOT EXISTS "raster_overviews" ( id SERIAL PRIMARY KEY );
"#;

api.raw_cmd(create_tables);
Expand All @@ -79,7 +81,9 @@ fn existing_postgis_tables_must_not_be_migrated(api: TestApi) {
api.assert_schema()
.assert_has_table("spatial_ref_sys")
.assert_has_table("Geometry_columns")
.assert_has_table("geography_columns");
.assert_has_table("geography_columns")
.assert_has_table("raster_columns")
.assert_has_table("raster_overviews");
}

// Reference for the views created by PostGIS: https://postgis.net/docs/manual-1.4/ch04.html#id418599
Expand Down

0 comments on commit fb56bfe

Please sign in to comment.