setup
CREATE DATABASE db1;
CREATE SCHEMA db1.sc1;
CREATE TABLE db1.sc1.t1 (
  id INT PRIMARY KEY,
  amount INT,
  CONSTRAINT t1_amount_gt_10 CHECK (amount > 10)
);
----

ops
COMMENT ON DATABASE db1 IS 'db1 is good';
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[DatabaseComment:{DescID: 104, Comment: db1 is good}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertDatabaseComment
      Comment: db1 is good
      DatabaseID: 104
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[DatabaseComment:{DescID: 104, Comment: db1 is good}, PUBLIC], PUBLIC] -> ABSENT
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[DatabaseComment:{DescID: 104, Comment: db1 is good}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertDatabaseComment
      Comment: db1 is good
      DatabaseID: 104

ops
COMMENT ON SCHEMA db1.sc1 IS 'sc1 is good';
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[SchemaComment:{DescID: 106, Comment: sc1 is good}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertSchemaComment
      Comment: sc1 is good
      SchemaID: 106
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[SchemaComment:{DescID: 106, Comment: sc1 is good}, PUBLIC], PUBLIC] -> ABSENT
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[SchemaComment:{DescID: 106, Comment: sc1 is good}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertSchemaComment
      Comment: sc1 is good
      SchemaID: 106

ops
COMMENT ON TABLE db1.sc1.t1 IS 't1 is good';
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[TableComment:{DescID: 107, Comment: t1 is good}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertTableComment
      Comment: t1 is good
      TableID: 107
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[TableComment:{DescID: 107, Comment: t1 is good}, PUBLIC], PUBLIC] -> ABSENT
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[TableComment:{DescID: 107, Comment: t1 is good}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertTableComment
      Comment: t1 is good
      TableID: 107

ops
COMMENT ON COLUMN db1.sc1.t1.id IS 'id is important';
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[ColumnComment:{DescID: 107, ColumnID: 1, Comment: id is important}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertColumnComment
      ColumnID: 1
      Comment: id is important
      TableID: 107
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[ColumnComment:{DescID: 107, ColumnID: 1, Comment: id is important}, PUBLIC], PUBLIC] -> ABSENT
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[ColumnComment:{DescID: 107, ColumnID: 1, Comment: id is important}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertColumnComment
      ColumnID: 1
      Comment: id is important
      TableID: 107

ops
COMMENT ON INDEX db1.sc1.t1_pkey IS 'pkey is good';
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[IndexComment:{DescID: 107, IndexID: 1, Comment: pkey is good}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertIndexComment
      Comment: pkey is good
      IndexID: 1
      TableID: 107
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[IndexComment:{DescID: 107, IndexID: 1, Comment: pkey is good}, PUBLIC], PUBLIC] -> ABSENT
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[IndexComment:{DescID: 107, IndexID: 1, Comment: pkey is good}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertIndexComment
      Comment: pkey is good
      IndexID: 1
      TableID: 107

ops
COMMENT ON CONSTRAINT t1_amount_gt_10 ON db1.sc1.t1 IS 'this is a rule';
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[ConstraintComment:{DescID: 107, ConstraintID: 2, Comment: this is a rule}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertConstraintComment
      Comment: this is a rule
      ConstraintID: 2
      TableID: 107
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[ConstraintComment:{DescID: 107, ConstraintID: 2, Comment: this is a rule}, PUBLIC], PUBLIC] -> ABSENT
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[ConstraintComment:{DescID: 107, ConstraintID: 2, Comment: this is a rule}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertConstraintComment
      Comment: this is a rule
      ConstraintID: 2
      TableID: 107

setup
COMMENT ON DATABASE db1 IS 'db1 is good';
COMMENT ON SCHEMA db1.sc1 IS 'sc1 is good';
COMMENT ON TABLE db1.sc1.t1 IS 't1 is good';
COMMENT ON COLUMN db1.sc1.t1.id IS 'id is important';
COMMENT ON INDEX db1.sc1.t1_pkey IS 'pkey is good';
COMMENT ON CONSTRAINT t1_amount_gt_10 ON db1.sc1.t1 IS 'this is a rule';
----

ops
COMMENT ON DATABASE db1 IS NULL;
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[DatabaseComment:{DescID: 104, Comment: db1 is good}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveDatabaseComment
      DatabaseID: 104
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[DatabaseComment:{DescID: 104, Comment: db1 is good}, ABSENT], ABSENT] -> PUBLIC
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[DatabaseComment:{DescID: 104, Comment: db1 is good}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveDatabaseComment
      DatabaseID: 104

ops
COMMENT ON SCHEMA db1.sc1 IS NULL;
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[SchemaComment:{DescID: 106, Comment: sc1 is good}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveSchemaComment
      SchemaID: 106
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[SchemaComment:{DescID: 106, Comment: sc1 is good}, ABSENT], ABSENT] -> PUBLIC
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[SchemaComment:{DescID: 106, Comment: sc1 is good}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveSchemaComment
      SchemaID: 106

ops
COMMENT ON TABLE db1.sc1.t1 IS NULL;
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[TableComment:{DescID: 107, Comment: t1 is good}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveTableComment
      TableID: 107
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[TableComment:{DescID: 107, Comment: t1 is good}, ABSENT], ABSENT] -> PUBLIC
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[TableComment:{DescID: 107, Comment: t1 is good}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveTableComment
      TableID: 107

ops
COMMENT ON COLUMN db1.sc1.t1.id IS NULL;
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[ColumnComment:{DescID: 107, ColumnID: 1, Comment: id is important}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveColumnComment
      ColumnID: 1
      PgAttributeNum: 1
      TableID: 107
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[ColumnComment:{DescID: 107, ColumnID: 1, Comment: id is important}, ABSENT], ABSENT] -> PUBLIC
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[ColumnComment:{DescID: 107, ColumnID: 1, Comment: id is important}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveColumnComment
      ColumnID: 1
      PgAttributeNum: 1
      TableID: 107

ops
COMMENT ON INDEX db1.sc1.t1_pkey IS NULL;
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[IndexComment:{DescID: 107, IndexID: 1, Comment: pkey is good}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveIndexComment
      IndexID: 1
      TableID: 107
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[IndexComment:{DescID: 107, IndexID: 1, Comment: pkey is good}, ABSENT], ABSENT] -> PUBLIC
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[IndexComment:{DescID: 107, IndexID: 1, Comment: pkey is good}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveIndexComment
      IndexID: 1
      TableID: 107

ops
COMMENT ON CONSTRAINT t1_amount_gt_10 ON db1.sc1.t1 IS NULL;
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[ConstraintComment:{DescID: 107, ConstraintID: 2, Comment: this is a rule}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveConstraintComment
      ConstraintID: 2
      TableID: 107
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[ConstraintComment:{DescID: 107, ConstraintID: 2, Comment: this is a rule}, ABSENT], ABSENT] -> PUBLIC
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[ConstraintComment:{DescID: 107, ConstraintID: 2, Comment: this is a rule}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveConstraintComment
      ConstraintID: 2
      TableID: 107

setup
CREATE TYPE roach_dwellings AS ENUM ('roach_motel','roach_kitchen','roach_bathroom','roach_house');
CREATE TYPE roach_legs AS (legs INT);
----

ops
COMMENT ON TYPE roach_dwellings IS 'First CRDB comment on types';
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 108, Comment: First CRDB comment on types}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertTypeComment
      Comment: First CRDB comment on types
      TypeID: 108
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 108, Comment: First CRDB comment on types}, PUBLIC], PUBLIC] -> ABSENT
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 108, Comment: First CRDB comment on types}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertTypeComment
      Comment: First CRDB comment on types
      TypeID: 108

ops
COMMENT ON TYPE roach_legs IS 'Second CRDB comment on types';
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 110, Comment: Second CRDB comment on types}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertTypeComment
      Comment: Second CRDB comment on types
      TypeID: 110
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 110, Comment: Second CRDB comment on types}, PUBLIC], PUBLIC] -> ABSENT
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 110, Comment: Second CRDB comment on types}, PUBLIC], ABSENT] -> PUBLIC
  ops:
    *scop.UpsertTypeComment
      Comment: Second CRDB comment on types
      TypeID: 110

setup
COMMENT ON TYPE roach_dwellings IS 'First CRDB comment on types';
COMMENT ON TYPE roach_legs IS 'Second CRDB comment on types';
----

ops
COMMENT ON TYPE roach_dwellings IS NULL;
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 108, Comment: First CRDB comment on types}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveTypeComment
      TypeID: 108
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 108, Comment: First CRDB comment on types}, ABSENT], ABSENT] -> PUBLIC
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 108, Comment: First CRDB comment on types}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveTypeComment
      TypeID: 108

ops
COMMENT ON TYPE roach_legs IS NULL;
----
StatementPhase stage 1 of 1 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 110, Comment: Second CRDB comment on types}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveTypeComment
      TypeID: 110
PreCommitPhase stage 1 of 2 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 110, Comment: Second CRDB comment on types}, ABSENT], ABSENT] -> PUBLIC
  ops:
    *scop.UndoAllInTxnImmediateMutationOpSideEffects
      {}
PreCommitPhase stage 2 of 2 with 1 MutationType op
  transitions:
    [[TypeComment:{DescID: 110, Comment: Second CRDB comment on types}, ABSENT], PUBLIC] -> ABSENT
  ops:
    *scop.RemoveTypeComment
      TypeID: 110
