From 6fd7acda34c19d10d59dff7f57b7c9a9371c2bc0 Mon Sep 17 00:00:00 2001 From: Paul Draper Date: Sun, 31 Jan 2021 20:46:05 -0700 Subject: [PATCH] Implement comments --- migra/changes.py | 1 + migra/migra.py | 1 + tests/FIXTURES/comments/a.sql | 1 + tests/FIXTURES/comments/additions.sql | 0 tests/FIXTURES/comments/b.sql | 5 +++++ tests/FIXTURES/comments/expected.sql | 10 ++++++++++ tests/FIXTURES/comments/expected2.sql | 0 tests/test_migra.py | 1 + 8 files changed, 19 insertions(+) create mode 100644 tests/FIXTURES/comments/a.sql create mode 100644 tests/FIXTURES/comments/additions.sql create mode 100644 tests/FIXTURES/comments/b.sql create mode 100644 tests/FIXTURES/comments/expected.sql create mode 100644 tests/FIXTURES/comments/expected2.sql diff --git a/migra/changes.py b/migra/changes.py index 264bb10..0ddc9d5 100644 --- a/migra/changes.py +++ b/migra/changes.py @@ -21,6 +21,7 @@ "collations", "rlspolicies", "triggers", + "comments", ] PK = "PRIMARY KEY" diff --git a/migra/migra.py b/migra/migra.py index 739b850..a52605c 100644 --- a/migra/migra.py +++ b/migra/migra.py @@ -111,6 +111,7 @@ def add_all_changes(self, privileges=False): self.add(self.changes.rlspolicies(creations_only=True)) self.add(self.changes.triggers(creations_only=True)) self.add(self.changes.collations(drops_only=True)) + self.add(self.changes.comments(creations_only=True)) self.add(self.changes.schemas(drops_only=True)) @property diff --git a/tests/FIXTURES/comments/a.sql b/tests/FIXTURES/comments/a.sql new file mode 100644 index 0000000..4bba508 --- /dev/null +++ b/tests/FIXTURES/comments/a.sql @@ -0,0 +1 @@ +create table example0 (a int); diff --git a/tests/FIXTURES/comments/additions.sql b/tests/FIXTURES/comments/additions.sql new file mode 100644 index 0000000..e69de29 diff --git a/tests/FIXTURES/comments/b.sql b/tests/FIXTURES/comments/b.sql new file mode 100644 index 0000000..ce61109 --- /dev/null +++ b/tests/FIXTURES/comments/b.sql @@ -0,0 +1,5 @@ +create table example (a int); + +comment on table example is 'Example table'; + +comment on column example.a is 'Example column'; diff --git a/tests/FIXTURES/comments/expected.sql b/tests/FIXTURES/comments/expected.sql new file mode 100644 index 0000000..9bd8563 --- /dev/null +++ b/tests/FIXTURES/comments/expected.sql @@ -0,0 +1,10 @@ +drop table "public"."example0"; + +create table "public"."example" ( + "a" integer +); + + +comment on column "public"."example"."a" is 'Example column'; + +comment on table "public"."example" is 'Example table'; diff --git a/tests/FIXTURES/comments/expected2.sql b/tests/FIXTURES/comments/expected2.sql new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_migra.py b/tests/test_migra.py index 94bb11d..dd22867 100644 --- a/tests/test_migra.py +++ b/tests/test_migra.py @@ -61,6 +61,7 @@ def test_singleschema_ext(): fixtures = """\ everything +comments collations identitycols partitioning