NAME

DBIO::Oracle::Diff::Table - Diff operations for Oracle tables

VERSION

version 0.900007

DESCRIPTION

Represents a table-level diff operation in Oracle: CREATE TABLE or DROP TABLE. A create op carries the whole table the way DBIO::Oracle::DDL writes it for the install: the columns with their defaults and NOT NULL, the primary key (from is_pk and pk_position of the columns), the unique constraints by name, and, for a column that a sequence feeds (is_auto_increment and sequence), the CREATE SEQUENCE and the BEFORE INSERT trigger after the table. Every name is written double-quoted, as the model spells it. The indexes of the new table are DBIO::Oracle::Diff::Index's and its foreign keys DBIO::Oracle::Diff::ForeignKey's, both after every CREATE TABLE.

What the model does not carry is not invented. It holds the sequence a column is filled from -- found by reading the BEFORE INSERT trigger -- but neither the name nor the text of that trigger; the diff writes the one the install writes (table_column_trg, shortened to 30 characters, WHEN (new.col IS NULL), SELECT seq.NEXTVAL INTO :new.col FROM DUAL), because the sequence is in the model only for the trigger's sake. A hand-written trigger of another shape therefore comes back in the install's form. A column that is auto-increment without a sequence (GENERATED ... AS IDENTITY) is refused with a DBIO exception: the model does not say whether the identity is ALWAYS or BY DEFAULT. So is a sequence of another schema than the table's, and a table the model gives no columns (there is no CREATE TABLE X ( )). The model records the sequence as the server spells it (a quoted name in its own case, a bare one in upper case) and it is written as that, quoted.

A drop op also drops the sequences the install made for the table: DROP TABLE takes the trigger along, not the sequence. They are those of the columns the source model has with is_auto_increment and a sequence of the table's own schema. A GENERATED ... AS IDENTITY column has no sequence in the model (Oracle owns that one and drops it with the table), a sequence of another schema is not the table's to drop, and one that a column of another table of the target model is still fed from stays.

A name the model records as a view (kind is view) is not this class's: views are DBIO::Oracle::Diff::View's. A name that is a table in one model and a view in the other is refused with a DBIO exception naming the object.

ATTRIBUTES

table_name

The table's key in the model: the bare name, or schema.table for a table of another schema, written "schema"."table".

table_info

Hashref of table metadata from introspection (kind, schema, etc.).

columns

ArrayRef of column hashrefs for new tables (populated when action is create), in the order of the table.

unique_constraints

ArrayRef of [ $name, \@columns ] pairs, the unique constraints of a new table (the unique_constraints section of the model), written inline in the CREATE TABLE.

sequences

ArrayRef of sequence names (without schema) that a drop op drops after the table.

METHODS

diff

my @ops = DBIO::Oracle::Diff::Table->diff(
    $source_tables, $target_tables,
    $target_columns, $target_unique_constraints, $source_columns,
);

The last three are the columns and unique_constraints sections of the target model and the columns section of the source model, keyed by table name. A table that only the target has needs columns there; one without is refused. The source columns tell which sequences a dropped table leaves.

as_sql

summary

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.