NAME
DBIO::Sybase::Diff::Table - Diff Sybase ASE tables
VERSION
version 0.900007
DESCRIPTION
Compares two table sets and generates table-level diff operations.
METHODS
diff_primary_keys
my @ops = DBIO::Sybase::Diff::Table->diff_primary_keys(
$source_tables, $target_tables,
$source_columns, $target_columns, $source_indexes,
);
Primary-key ops for the tables present on both sides: a DBIO::Sybase::Diff::Table::PrimaryKey::Drop (action drop) when the source has a key that differs from the target's or the target has none, and a ...::PrimaryKey::Add (action create) when the target has a key that differs from the source's or the source has none. See "THE PRIMARY KEY IS PART OF THE TABLE".
THE PRIMARY KEY IS PART OF THE TABLE
A created table carries its PRIMARY KEY in the CREATE TABLE, columns in pk_position order -- the key order the catalog reports, which DBIO::Sybase::Introspect marks on the columns. A table added through "upgrade" in DBIO::Sybase::Deploy keeps its key.
For a table on both sides "diff_primary_keys" compares the key as the ordered column list, never by name: ASE names the constraint after the object id (artist_5760020521), so the live name and the one in the compare database never agree (the same reason DBIO::Sybase::Diff::Index leaves the PK index out). A changed, added or removed key becomes
ALTER TABLE t DROP CONSTRAINT <live name>;
ALTER TABLE t ADD PRIMARY KEY (a, b);
-- the drop naming the source side's PK index, which in ASE is the constraint (it is not listed in sysconstraints). ASE has no in-place change and refuses a second key (Msg 1923), so it is always the drop and then the add, both accepted on ASE 16.0 SP02. DBIO::Sybase::Diff places the drop before the column diff (a key column may be about to be dropped) and the add after it (a key column may be about to be added, or made NOT NULL).
A key still referenced by a foreign key cannot be dropped (Msg 3712 "Cannot drop index ... because it still has referential integrity constraints"). The diff drops a foreign key only when the desired model no longer has it, so a key change under an unchanged reference fails at that statement.
IDENTITY ON A NUMERIC COLUMN ONLY
A column marked is_auto_increment is created <type> IDENTITY. ASE takes that attribute on an integer or NUMERIC(p,0) column only, so the CREATE TABLE of a table with such a column of a type known not to take it is refused -- as_sql croaks naming table, column and type -- under the rule and with the type list of "install_ddl" in DBIO::Sybase::DDL, the other emitter of this column grammar.
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.