我一直在嘗試爲跨dbms數據庫使用遷移。使用委託和confide包,我在它們後面添加了遷移,以將user_statuses表和用戶表中的引用添加到user-status的ID;但我定義的外鍵我得到這個:Laravel-OCI8 ORA-02275:表中已經存在這樣的參考約束
[Illuminate\Database\QueryException] Error Code : 2275 Error Message : ORA-02275: such a referential constraint already exists in the table Position : 53 Statement : alter table users add constraint users_state_foreign foreign key (state) references user_statuses (id) (SQL: alter table users add constraint users_state_foreign foreign key (state) references user_statuses (id)) [yajra\Pdo\Oci8\Exceptions\SqlException] Error Code : 2275 Error Message : ORA-02275: such a referential constraint already exists in the table Position : 53 Statement : alter table users add constraint users_state_foreign foreign key (state) peferences user_statuses (id)
以下是user_statuses和更改遷移。 user_status創作:
Schema::create('user_statuses', function($table){
// Columns
$table->increments('id')->unsigned();
$table->string('name');
// Indexes
// Constraints
});
用戶改變:
Schema::table('users',function($table){
// Columns
$table->integer('state')->unsigned();
$table->softDeletes();
// Indexed
// Constraints
$table->foreign('state')->references('id')->on('user_statuses');
});
您正在使用的數據庫已經有一個名爲'USERS_STATE_FOREIGN'的約束。嘗試執行以下操作:'SELECT * FROM ALL_CONSTRAINTS WHERE CONSTRAINT_NAME ='USERS_STATE_FOREIGN''。祝你好運。 – 2014-08-31 12:33:52
謝謝@BobJarvis!我運行一個新的數據庫遷移(我甚至清除其餘的)。我試圖改變約束的名稱,列名。我刪除了我知道的外鍵定義,並且不會有任何約束。我用mysql測試了遷移,他們似乎沒問題。我運行純粹的查詢,他們都沒問題。我有可能認爲這可能需要對yajra/laravel-oci8軟件包或遷移本身進行一些操作,它會多次調用該線路! – Cunning 2014-08-31 13:05:32
就我個人而言,我不會使用任何種類的數據庫「框架」,因爲我的觀察是他們引起的問題比他們解決的問題多。因人而異。 – 2014-08-31 16:37:35