1
I know with migration
I can create the tables, but it has some form of automates even the creation of the bank with the migration
to follow as basis I use the Laravel 5.2
1
I know with migration
I can create the tables, but it has some form of automates even the creation of the bank with the migration
to follow as basis I use the Laravel 5.2
2
According to the documentation as migrations
do not create the database:
Migrations
are like version control for your database, allowing a team to modify and share the schema
of the application easily.
The Laravel
Schema
facade
provides agnostic support for creating and manipulating tables. It shares the same model, API
fluente
all database systems supported by Laravel
. doc
Something that can be done is to create a file PHP
to do this.
Example:
$pdo = $db->connect();
// ---------------------------------------------------------------------------------------
$query = "DROP DATABASE IF EXISTS `{$dbName}`";
$pdo->exec($query);
$query = "CREATE DATABASE `{$dbName}`";
$pdo->exec($query);
$query = "USE `{$dbName}`";
$pdo->exec($query);
// ---------------------------------------------------------------------------------------
$query = "
CREATE TABLE `clientes` (
`id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`nome` VARCHAR(255) NOT NULL,
`endereco` VARCHAR(255) NOT NULL,
`enderecoCobranca` VARCHAR(255) NULL,
`importancia` INT(1) UNSIGNED NOT NULL,
`tipoCliente` VARCHAR(10) NOT NULL,
`numId` VARCHAR(18) NOT NULL
)";
$pdo->exec($query);
Browser other questions tagged php laravel-5
You are not signed in. Login or sign up in order to post.
To automate this with Laravel, you know how I do ? Ask to run this script from the outside ?
– Renan Rodrigues
to run just give a require "file name". But the problem of this is to close very well to it to do only if there is no bank. to see you lose your application
– Israel Zebulon