|
@@ -150,8 +150,9 @@ Ejemplo para hacer una tabla, llave primaria, llave foránea.
|
|
|

|
|
|
|
|
|
```
|
|
|
-php yii migrate/create tbl_ra
|
|
|
+php yii migrate/create tbl_ra
|
|
|
```
|
|
|
+
|
|
|

|
|
|
|
|
|
Comando para dar downgrade a la migración.
|
|
@@ -160,7 +161,6 @@ Comando para dar downgrade a la migración.
|
|
|
php yii migrate/down
|
|
|
```
|
|
|
|
|
|
-
|
|
|
Codigo para crear dos entidades Producto Categoria
|
|
|
<br> **archivo:m240201_185131_tbl_test.php**
|
|
|
|
|
@@ -185,13 +185,13 @@ class m240201_185131_tbl_test extends Migration
|
|
|
"idCategoria" => $this->string(36),
|
|
|
"clave" => $this->string(20),
|
|
|
"nombre" => $this->string("255"),
|
|
|
- "descripcion" => $this->string("255"),
|
|
|
+ "descripcion" => $this->string("255"),
|
|
|
"idUsuarioCreador" => $this->integer(),
|
|
|
"creado" => $this->timestamp() . " with time zone",
|
|
|
"modificado" => $this->timestamp() . " with time zone",
|
|
|
"eliminado" => $this->timestamp() . " with time zone",
|
|
|
- ]);
|
|
|
-
|
|
|
+ ]);
|
|
|
+
|
|
|
$this->addPrimaryKey('ProductoPK', 'Producto', 'idProducto');
|
|
|
|
|
|
$this->createTable('Categoria', [
|
|
@@ -203,11 +203,11 @@ class m240201_185131_tbl_test extends Migration
|
|
|
"creado" => $this->timestamp() . " with time zone",
|
|
|
"modificado" => $this->timestamp() . " with time zone",
|
|
|
"eliminado" => $this->timestamp() . " with time zone",
|
|
|
- ]);
|
|
|
-
|
|
|
+ ]);
|
|
|
+
|
|
|
$this->addPrimaryKey('CategoriaPK', 'Categoria', 'idCategoria');
|
|
|
-
|
|
|
- $this->addForeignKey('ProductoIdCategoriaFK', 'Producto', 'idCategoria', 'Categoria', 'idCategoria');
|
|
|
+
|
|
|
+ $this->addForeignKey('ProductoIdCategoriaFK', 'Producto', 'idCategoria', 'Categoria', 'idCategoria');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -216,10 +216,10 @@ class m240201_185131_tbl_test extends Migration
|
|
|
public function safeDown()
|
|
|
{
|
|
|
echo "m240201_185131_tbl_test cannot be reverted.\n";
|
|
|
- $this->dropForeignKey('ProductoIdCategoriaFK', 'Producto');
|
|
|
+ $this->dropForeignKey('ProductoIdCategoriaFK', 'Producto');
|
|
|
$this->dropTable("Producto");
|
|
|
$this->dropTable("Categoria");
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -283,7 +283,6 @@ Ejemplo generación de modelos Producto y Categoria
|
|
|
|
|
|

|
|
|
|
|
|
-
|
|
|
### 9. Modelos a través del Yii 2
|
|
|
|
|
|
Archivo generado en la carpeta "models"; normalizar la nomeclatura de los modificadores de acceso, ya que en veces el modelo en atributeLabels se genera con plurales o “s”, etc.
|
|
@@ -301,7 +300,7 @@ Generar en el directorio models del módulo donde estemos trabajando (por lo gen
|
|
|
|
|
|
**ejemplo**
|
|
|

|
|
|
-el modelo que está en la raíz debe heredar de ModeloBase **Solo para cuando se tenga implementada en codigo la clase, en su mayoria para cuando se generan los id's del tipo UUID string(32)
|
|
|
+el modelo que está en la raíz debe heredar de ModeloBase \*\*Solo para cuando se tenga implementada en codigo la clase, en su mayoria para cuando se generan los id's del tipo UUID string(32)
|
|
|

|
|
|
|
|
|
### 10. Configuración de Controladores.
|