2
我正在從Oracle遷移到Postgresql。 我們一直在遷移Liquibase一段時間,但從一開始就不是。現在我正在努力添加和調整遷移以完全部署數據庫並在那裏傳輸數據。liquibase約束創建表的參考
現在我遇到了這樣一個問題,我沒有創建一個列與另一個表有關聯的約束的表。由於在約束中的表之前明確指定的方案,因此不會獲取此限制。
如何在具有未指定方案的表的約束中指定使用默認方案?
使用Maven插件 liquibase-行家-插件 3.5.3
下面是屬性:
Url: jdbc: postgresql: //192.168.1.1: 5432/postgres
DefaultSchemaName: ist
ReferencedTableSchemaName: ist
Username: test
Password: 123
Verbose: true
DropFirst: false
這裏是遷移片
- createTable:
TableName: opr_possibilities
Remarks: Operator capability map
Columns:
- column:
Name: id
Type: number (11)
Remarks: ID
Constraints:
Nullable: false
PrimaryKey: true
- column:
Name: operator_id
Type: number (11)
Remarks: Operator ID
Constraints:
Nullable: false
ForeignKeyName: fk_possibility_operator
References: ds_obj_opr (id)
# ReferencedTableName: ds_obj_opr
# ReferencedColumnNames: id
遷移產生這樣的請求:
CREATE TABLE ist.opr_possibilities (
id numeric(11) NOT NULL,
operator_id numeric(11) NOT NULL,
begin_date date DEFAULT NOW() NOT NULL,
end_date date DEFAULT NOW() NOT NULL,
duty BOOLEAN DEFAULT FALSE NOT NULL,
status numeric(4) DEFAULT 0 NOT NULL,
type numeric(4) DEFAULT 0 NOT NULL,
remarks VARCHAR(255),
CONSTRAINT PK_OPR_POSSIBILITIES PRIMARY KEY (id),
CONSTRAINT fk_possibility_operator FOREIGN KEY (operator_id) REFERENCES ds_obj_opr(id)
)
請告訴我如何優雅地解決這個問題。 謝謝。
是的,你是對的,我沒有考慮這些決定作爲優雅) 但我認爲這個問題是一個錯誤。 爲什麼不是「defaultSchemaName」用於「參考」? 正如「addForeignKeyConstraint」「constraintName」不注意「objectQuotingStrategy」=「QUOTE_ALL_OBJECTS」 但是現在我通過變量應用模式指定,因爲在我們的遷移中使用了Native查詢。 但謝謝你的回答) – Alex