Hola y bienvenido.
En esta clase, lo que hacemos es ir a la carpeta: database/migrations/...create_agendas_table.php
En este vamos a modificar la funcion up()
antes:
public function up()
{
Schema::create('agendas', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
});
}
Después:
public function up()
{
Schema::create('agendas', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('nombres',50);
$table->string('apellidos',50);
$table->string('telefono',20);
$table->string('celular',20);
$table->char('sexo',9);
$table->string('email',50);
$table->string('posicion',100);
$table->string('departamento',100);
$table->decimal('salario',10,2);
$table->date('fechadenacimiento');
$table->timestamps();
});
}
Luego abrimos el terminal y ejecutamos
php artisan migrate
y debe salir algo como esto:
jyc@jyc-Inspiron-5555:~/Escritorio/laravel6/agendatelefonica$ php artisan migrate
Migrating: 2019_10_05_055125_create_agendas_table
Migrated: 2019_10_05_055125_create_agendas_table (0.28 seconds)
pero si le sale esto:
jyc@jyc-Inspiron-5555:~/Escritorio/laravel6/agendatelefonica$ php artisan migrate
Nothing to migrate.
Es porque ya habían ejecutado antes el php artisan migrate.
Lo que deben hacer es ejecutar primero el comando:
php aritsan migrate:reset
Para eliminar todas las tablas y luego hacer otra vez un
php artisan migrate
para volver a subir todas las tablas y listo.
Si queremos, podemos acceder a mysql y verificar si se crearon las tablas:
adjunto los comandos:
jyc@jyc-Inspiron-5555:~/Escritorio/laravel6/agendatelefonica$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.27-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use agendatelefonica
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_agendatelefonica |
+----------------------------+
| agendas |
| failed_jobs |
| migrations |
| password_resets |
| users |
+----------------------------+
5 rows in set (0.00 sec)
mysql> desc agendas
-> ;
+-------------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------+----------------+
| id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
| nombres | varchar(50) | NO | | NULL | |
| apellidos | varchar(50) | NO | | NULL | |
| telefono | varchar(20) | NO | | NULL | |
| celular | varchar(20) | NO | | NULL | |
| sexo | char(9) | NO | | NULL | |
| email | varchar(50) | NO | | NULL | |
| posicion | varchar(100) | NO | | NULL | |
| departamento | varchar(100) | NO | | NULL | |
| salario | decimal(10,2) | NO | | NULL | |
| fechadenacimiento | date | NO | | NULL | |
| created_at | timestamp | YES | | NULL | |
| updated_at | timestamp | YES | | NULL | |
+-------------------+---------------------+------+-----+---------+----------------+
13 rows in set (0.01 sec)
mysql>
Espero que les haya gustado.
Saludos y Dios les bendiga.
Curso Relacionado