const CREATE_TABLE_METADATA_TABLE = (
  /*sql*/
  `
  CREATE TABLE "_zero.tableMetadata" (
    "schema"   TEXT NOT NULL,
    "table"    TEXT NOT NULL,
    "metadata" TEXT NOT NULL,
    PRIMARY KEY ("schema", "table")
  );
`
);
class TableMetadataTracker {
  #set;
  #rename;
  #drop;
  constructor(db) {
    this.#set = db.prepare(
      /*sql*/
      `
      INSERT OR REPLACE INTO "_zero.tableMetadata"
        ("schema", "table", "metadata") VALUES (?, ?, ?);
    `
    );
    this.#rename = db.prepare(
      /*sql*/
      `
      UPDATE "_zero.tableMetadata" SET "schema" = ?, "table" = ?
        WHERE "schema" = ? AND "table" = ?
    `
    );
    this.#drop = db.prepare(
      /*sql*/
      `
      DELETE FROM "_zero.tableMetadata" WHERE "schema" = ? AND "table" = ?
    `
    );
  }
  set({ schema, name }, metadata) {
    this.#set.run(schema, name, JSON.stringify(metadata));
  }
  rename(oldTable, newTable) {
    this.#rename.run(
      newTable.schema,
      newTable.name,
      oldTable.schema,
      oldTable.name
    );
  }
  drop({ schema, name }) {
    this.#drop.run(schema, name);
  }
}
export {
  CREATE_TABLE_METADATA_TABLE,
  TableMetadataTracker
};
//# sourceMappingURL=table-metadata.js.map
