|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
-
-
-
-
-
-
-
- echo "<?php\n";
- if (!empty($namespace)) {
- echo "\nnamespace {$namespace};\n";
- }
- ?>
-
- use yii\db\Migration;
-
-
- class <?= $className ?> extends Migration
- {
-
-
- public function up()
- {
- $this->createTable('<?= $table ?>', [
- '<?= $field_first ?>_id' => $this->integer(),
- '<?= $field_second ?>_id' => $this->integer(),
- 'PRIMARY KEY(<?= $field_first ?>_id, <?= $field_second ?>_id)',
- ]);
-
- $this->createIndex(
- 'idx-<?= $table . '-' . $field_first ?>_id',
- '<?= $table ?>',
- '<?= $field_first ?>_id'
- );
-
- $this->createIndex(
- 'idx-<?= $table . '-' . $field_second ?>_id',
- '<?= $table ?>',
- '<?= $field_second ?>_id'
- );
-
- $this->addForeignKey(
- 'fk-<?= $table . '-' . $field_first ?>_id',
- '<?= $table ?>',
- '<?= $field_first ?>_id',
- '<?= $field_first ?>',
- 'id',
- 'CASCADE'
- );
-
- $this->addForeignKey(
- 'fk-<?= $table . '-' . $field_second ?>_id',
- '<?= $table ?>',
- '<?= $field_second ?>_id',
- '<?= $field_second ?>',
- 'id',
- 'CASCADE'
- );
- }
-
-
-
- public function down()
- {
- $this->dropTable('<?= $table ?>');
- }
- }
|