|
@@ -149,6 +149,84 @@ Pasos detallados sobre la creación de tablas específicas, asegurando la cohere
|
|
Ejemplo para hacer una tabla, llave primaria, llave foránea.
|
|
Ejemplo para hacer una tabla, llave primaria, llave foránea.
|
|

|
|

|
|
|
|
|
|
|
|
+Codigo para crear dos entidades Producto Categoria
|
|
|
|
+
|
|
|
|
+```php
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+use yii\db\Migration;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Class m240201_185131_tbl_test
|
|
|
|
+ */
|
|
|
|
+class m240201_185131_tbl_test extends Migration
|
|
|
|
+{
|
|
|
|
+ /**
|
|
|
|
+ * {@inheritdoc}
|
|
|
|
+ */
|
|
|
|
+ public function safeUp()
|
|
|
|
+ {
|
|
|
|
+ $this->createTable('Producto', [
|
|
|
|
+ // "idProducto" => $this->primaryKey(), // Esta es una manera de volver llave primaria
|
|
|
|
+ "idProducto" => $this->string(36), // UUID es por eso el 36
|
|
|
|
+ "idCategoria" => $this->string(36),
|
|
|
|
+ "clave" => $this->string(20),
|
|
|
|
+ "nombre" => $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', [
|
|
|
|
+ "idCategoria" => $this->string(36),
|
|
|
|
+ "clave" => $this->string(20),
|
|
|
|
+ "nombre" => $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('CategoriaPK', 'Categoria', 'idCategoria');
|
|
|
|
+
|
|
|
|
+ $this->addForeignKey('ProductoIdCategoriaFK', 'Producto', 'idCategoria', 'Categoria', 'idCategoria');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * {@inheritdoc}
|
|
|
|
+ */
|
|
|
|
+ public function safeDown()
|
|
|
|
+ {
|
|
|
|
+ echo "m240201_185131_tbl_test cannot be reverted.\n";
|
|
|
|
+ $this->dropForeignKey('ProductoIdCategoriaFK', 'Producto');
|
|
|
|
+ $this->dropTable("Producto");
|
|
|
|
+ $this->dropTable("Categoria");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ // Use up()/down() to run migration code without a transaction.
|
|
|
|
+ public function up()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function down()
|
|
|
|
+ {
|
|
|
|
+ echo "m240201_185131_tbl_test cannot be reverted.\n";
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
### 7. Inicialización del servidor PHP.
|
|
### 7. Inicialización del servidor PHP.
|
|
|
|
|
|
Instrucciones para inicializar el servidor PHP y poner en marcha la aplicación localmente.
|
|
Instrucciones para inicializar el servidor PHP y poner en marcha la aplicación localmente.
|