Čamo
1 month ago
235
3
General

Migration for creating database

Posted 1 month ago by Čamo

Hi, is it possible to create database with migrations. I try to make migration for it but it throws me an error: SQLSTATE[HY000] [1049] Unknown database 'laravel-react' (SQL: select * from information_schema.tables where table_schema = laravel-react and table_name = migrations and table_type = 'BASE TABLE')

    public function up()
    {
		DB::statement('
			CREATE DATABASE IF NOT EXISTS laravel-react 
			DEFAULT CHARACTER SET utf8mb4 
			COLLATE utf8mb4_slovak_ci;
			USE laravel-react;
		');
    }

I would like to have DB creation included in migrations not as a separate artisan command.

Please sign in or create an account to participate in this conversation.