G
G
Gip2019-03-28 04:41:05
Oracle
Gip, 2019-03-28 04:41:05

Yii2 migrations to Oracle?

Migrations have strange behavior when I changed the connection from Posgresql to Oracle.
See:

class m190325_054540_add_table_news extends Migration {

  public function safeUp() {
    $this->createTable('news', [
      'id'           => Schema::TYPE_PK,
      'old_id'       => Schema::TYPE_INTEGER . ' NOT NULL',
      'category_id'  => Schema::TYPE_SMALLINT . ' NOT NULL',
      'date'         => Schema::TYPE_DATETIME . ' NOT NULL',
      'title'        => Schema::TYPE_STRING . ' NOT NULL',
      'text'         => Schema::TYPE_TEXT . ' NOT NULL',
      'is_published' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT false',
      'is_hot'       => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT false',
      'image'        => Schema::TYPE_STRING,
      'lang'         => Schema::TYPE_STRING,
      'insert_stamp' => Schema::TYPE_DATETIME . ' NOT NULL',
      'update_stamp' => Schema::TYPE_DATETIME . ' NOT NULL',
    ]);


    $this->createIndex('ix-old-id', 'news', 'old_id', true);
    $this->createIndex('ix-cat-dt-pub-l', 'news', ['category_id', 'date', 'is_published', 'lang']);
  }

  /**
   * {@inheritdoc}
   */
  public function safeDown() {
    $this->dropTable('news');
  }
}

the usual simple migration to postgres goes without problems. Orakl swears like this: Exception: ORA-00907: missing right parenthesis.
What right parenthesis does he need? For what? In this case, the table is created, but the entry about the applied migration does not appear in the label where it should be.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gip, 2019-03-28
@Giperoglif

in general, some kind of nonsense ... Yii makes a migration table, and the second time when you run yii migrate, it does not see it and tries to re-create it:

'ORA-00955: name is already used by an existing object
The SQL being executed was: CREATE TABLE "migration" (
  "version" varchar(180) NOT NULL PRIMARY KEY,
  "apply_time" NUMBER(10,0)
)'

Why is Oracle???(((
And the funniest thing is that this is the 12th oracle, but I still have a connection to the 11th. So I change it to it and everything is fine there too. Lol cake cheburek.
upd...
migration is defeated. cheerful Oracle will give me a lot more pleasure:
DEFAULT ON NULL 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question