phalcon / migrations

Generate or migrate database changes via migrations.
https://docs.phalcon.io/latest/en/db-migrations
BSD 3-Clause "New" or "Revised" License
28 stars 23 forks source link

Migration run wouldn't create mysql view #129

Closed scrptd95 closed 2 years ago

scrptd95 commented 2 years ago

Expected and Actual Behavior

Hi Guys, recently i created a view in my mysql db and was curious if the phalcon/migrations util would pick it up. I ran phalcon migrations generate to generate the migration file, wiped my tables and executed phalcon migrations run to check whether my db will be correctly created or not.

Migration File: `<?php

use Phalcon\Db\Column; use Phalcon\Db\Exception; use Phalcon\Db\Index; use Phalcon\Db\Reference; use Phalcon\Migrations\Mvc\Model\Migration;

/**

Create table syntax of created table via migration run: CREATE TABLEviolations( violationsdecimal(32,0) DEFAULT NULL, logged_forint NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

The table gets created but not as a view. It seems that the TABLE_TYPE gets ignored ? Also i'm curious where or if the migration generate task stores/saves the query related to the view.

Expected behavior:

Details

Jeckerson commented 2 years ago

Hello, this is new feature. At that moment there is no logic to auto detect SQL View and create it via morph() method.

What you can do now, is to create empty migration and put SQL code of view creation inside up() method, example:

public function up()
{
   $this->getConnection()->execute('CREATE VIEW ...');
}
scrptd95 commented 2 years ago

Ah thx for the hint. For now i'll handle it this way.

Also thank you for your fast response!

secgin commented 2 years ago

Hi, How can I manage the migrate order? Views should run last.