Part 9 - Migration Basics [How to Build a Blog with Laravel 5 Series]

Part 9 - Migration Basics [How to Build a Blog with Laravel 5 Series]

DevMarketer

8 лет назад

65,180 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@hichamabboud9672
@hichamabboud9672 - 11.03.2020 02:54

great job thank you. I have ONE QUESTION PLEASE. is it possible to connect one Application to two Databases? thx

Ответить
@peterdepra
@peterdepra - 03.01.2020 12:27

How can ANYBODY justify giving this guy a thumbs down? Absolutely nobody does it better than him!

Ответить
@zackogoma2800
@zackogoma2800 - 02.10.2019 17:41

I salute you

Ответить
@caroldanvers265
@caroldanvers265 - 29.06.2019 16:36

It doesn't work in version 7.1

Ответить
@dmgj4946
@dmgj4946 - 11.02.2019 15:31

Did posts table get there automatically from doing that migration or is that from model Post?

Ответить
@dmgj4946
@dmgj4946 - 11.02.2019 14:06

I see picture for last video but i can't click it

Ответить
@akarshskeyboardmania9021
@akarshskeyboardmania9021 - 24.11.2018 15:08

When I am doing php artisan migrate, I am getting this error:

Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] No connection co
uld be made because the target machine actively refused it.
(SQL: select * from information_schema.tables where table_schema = blog and tab
le_name = migrations)

at C:\wamp64\www\57\vendor\laravel\framework\src\Illuminate\Database\Connectio
n.php:664
660| // If an exception occurs when attempting to run a query, we'll
format the error
661| // message to include the bindings with SQL, which will make th
is exception a
662| // lot more helpful to the developer instead of just the databa
se's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|

Exception trace:

1 PDOException::("SQLSTATE[HY000] [2002] No connection could be made because
the target machine actively refused it.
")
C:\wamp64\www\57\vendor\laravel\framework\src\Illuminate\Database\Connecto
rs\Connector.php:70

2 PDO::__construct("mysql:host=localhost;port=8000;dbname=blog", "root", "",
[])
C:\wamp64\www\57\vendor\laravel\framework\src\Illuminate\Database\Connecto
rs\Connector.php:70

Please use the argument -v to see more details.

I am using laravel 5.7.14 and wamp server, please help me to get out of this error. Thank you so much in advance.

Ответить
@amirdajanovic647
@amirdajanovic647 - 08.11.2018 00:08

Please help!!
Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations)
after I run php artisan migration
I use XAMPP....but everytime one table is created, no more!!
please help THX

Ответить
@bawapulang2402
@bawapulang2402 - 27.07.2018 09:22

syntax error, unexpected '$post' (T_VARIABLE), expecting ')'

Ответить
@vishalsharma-bp9zu
@vishalsharma-bp9zu - 30.06.2018 16:55

hey, i am using xampp in windows, can you help me to set up database through that

Ответить
@paragchirde4138
@paragchirde4138 - 22.06.2018 15:30

I have been trying to migrate but it keeps me giving this error
Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = blog_demo and table_name = migrations)
And it says connection refused. Whats the problem here?

Ответить
@programmingmindset
@programmingmindset - 19.06.2018 12:09

Those who are facing error during migration access violation 1071 too long. use the following code
after first
use Illuminate\Support\Facades\Schema;

after that paste
Schema::defaultStringLength(191);
inside boot method

Ответить
@ramisweyri218
@ramisweyri218 - 17.05.2018 23:44

I have this err , and i try all slotions and nothing work,

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))

at C:\Users\fauzia hariri\Desktop\Sites\blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:665
661| // If an exception occurs when attempting to run a query, we'll format the error
662| // message to include the bindings with SQL, which will make this exception a
663| // lot more helpful to the developer instead of just the database's errors.
664| catch (Exception $e) {
> 665| throw new QueryException(
666| $query, $this->prepareBindings($bindings), $e
667| );
668| }
669|

Exception trace:

1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
C:\Users\fauzia hariri\Desktop\Sites\blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:459

2 PDOStatement::execute()
C:\Users\fauzia hariri\Desktop\Sites\blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:459

Please use the argument -v to see more details.

Ответить
@22buddie35
@22buddie35 - 09.05.2018 08:55

why is it that there is an error when I migrate the error is something like this " Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access
violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: a
lter table `users` add unique `users_email_unique`(`email`))

at C:\xampp\htdocs\blog\vendor\laravel\framework\src\Illuminate\Database\Conne
ction.php:664
660| // If an exception occurs when attempting to run a query, we'll
format the error
661| // message to include the bindings with SQL, which will make th
is exception a
662| // lot more helpful to the developer instead of just the databa
se's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|

Exception trace:

1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Sp
ecified key was too long; max key length is 767 bytes")
C:\xampp\htdocs\blog\vendor\laravel\framework\src\Illuminate\Database\Conn
ection.php:458

2 PDOStatement::execute()
C:\xampp\htdocs\blog\vendor\laravel\framework\src\Illuminate\Database\Conn
ection.php:458

Please use the argument -v to see more details.

Ответить
@jaikangammalangmei8271
@jaikangammalangmei8271 - 21.04.2018 14:34

sir what is 'forge' in the database.php ///// 'database' => env('DB_DATABASE', 'forge'),

Ответить
@ababibearakazaavelin2585
@ababibearakazaavelin2585 - 18.04.2018 11:47

For those who use laravel 5.6.16 go in migrations and in the email use a number of varchar inferior to 250 and the problem of long value will be fixed

Ответить
@RubemdeSousa
@RubemdeSousa - 07.03.2018 16:40

I love you, man! :D

Ответить
@jh-to4us
@jh-to4us - 22.01.2018 18:27

Thank you so much for making these videos :)

Ответить
@NoahNobody
@NoahNobody - 09.01.2018 15:27

XAMPP is a great way of running MySQL on Windows, and I think you might even get MySQLAdmin included. You will need to have Apache launched for that to work too though.

Ответить
@kunalusapkar3149
@kunalusapkar3149 - 19.12.2017 22:02

If You Are facing problem in laravel 5.4 , like Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes ,then Do this :
1.Go to AppServiceProvider.php , which is inside. App->Auth->Provider.
2.Then Add use Illuminate\Support\Facades\Schema; on Top
3.and inside Boot() add this , Schema::defaultStringLength(119);

Problem Solved
if not solved by the above solution

then try this
in database.php
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',

Ответить
@somerandomchannel382
@somerandomchannel382 - 11.12.2017 23:25

Part 9: Migration Basics
php artisan make:model Post --migration
Go to : database\migrations\2017_12_11_131619_create_prosts_table.php

public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->string('body');
$table->timestamps();
});
}

** Create a Database and Write it into in .env **
php artisan migrate

Ответить
@ephraimlambarte8610
@ephraimlambarte8610 - 07.12.2017 16:01

this guy deserves more likes and subscribers

Ответить
@Aditya-zz1mf
@Aditya-zz1mf - 10.11.2017 18:40

[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'App\Providers\ServiceProvider' not found


How to solve this error in laravel 5.5

Ответить
@jaybhutada5174
@jaybhutada5174 - 31.10.2017 19:38

wtf ...everything was going great and u couldnt use workstation that could be used by everyone...!!

Ответить
@Kliamframe
@Kliamframe - 10.10.2017 23:58

If you have problems - Maybe this will help:
When you install mysql it will give you a temporary password, which will expire.

First off all check if you can run mysql through terminal, by writing: mysql
If not then write: export PATH=$PATH:/usr/local/mysql/bin

Now you can write: mysql -u root -p and then: SET PASSWORD = PASSWORD(’some-password’);
And connect with sequel pro using your new password.
And now it works! Don’t know exactly why.. But it does :)

I’ve got a lot of problems getting mysql to work and i’ve just been using MAMP.

Ответить
@prakashale1627
@prakashale1627 - 01.10.2017 06:37

awesome mate

Ответить
@lukasglaser2
@lukasglaser2 - 19.08.2017 18:55

Is there any simple way to add a new column to a database table without making an additional migration? I want to update the existing migration and run a command like "migration-update"? Does anybody have an idea for me?

Ответить
@Sergeak21
@Sergeak21 - 27.07.2017 20:21

hey please help me to configure MAMP because I am getting an error saying Database [MAMP] not configured

Ответить
@subashdevkota39
@subashdevkota39 - 25.07.2017 18:51

you are awesome tutorial teacher i have ever watached teaching each and everythings vividly tq so much sir

Ответить
@peterm.souzajr.2112
@peterm.souzajr.2112 - 16.07.2017 02:04

officially stuck on this version of the blog and the advanced version.... i follow the steps exactly but some erors happen, please help with errors to continue with tutorials

Ответить
@candybar4761
@candybar4761 - 09.07.2017 16:04

When I tried to start migration I received an error:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 107
1 Specified key was too long; max key length is 1000 b
ytes (SQL: alter table `password_resets` add index `pa
ssword_resets_email_index`(`email`))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 107
1 Specified key was too long; max key length is 1000 b
ytes

Later I just updated info here: config\database.php
Changed to: 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci'
From: 'charset' => 'utf8m4b', 'collation' => 'utf84b_unicode_ci'

Is this change going to be crucial for upcoming work? Thanks!

Ответить
@BneiAnusim
@BneiAnusim - 06.07.2017 03:26

Not sure? Try first $mysql --version, to check if you have it already installed.

Ответить
@rupakkatwal9572
@rupakkatwal9572 - 30.06.2017 14:01

C:\xampp\htdocs\laravel>php artisan migrate
Migration table created successfully.


[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQ
L: alter table `users` add unique `users_email_unique`(`email`))



[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

THIS ERR OCCURED .MIGRATION AND USER table is created but not the post table.i am doing in the xampp

Ответить
@Kliamframe
@Kliamframe - 26.06.2017 23:06

Using MAMP? Write localhost:8889 at the .env - Took me a while to figure out.

Ответить
@dasicoder
@dasicoder - 18.06.2017 23:22

broo bro when i use php artisan make:model Post --migration
its makes one file in app the name of this file is Post.php but other file is not created in the migration folder
please guide me waiting for your response

Ответить
@gorankrgovic4406
@gorankrgovic4406 - 15.06.2017 00:04

No offense, but too much wasted time. If you want to learn someone to use Laravel, there is no need to learn them how to use SQL databases and how-to install different shit. Laravel, and any of PHP frameworks out there, are reserved for the people who already KNOW how to code. Frameworks are not for beginners in any programming language cause they need to learn to code from the ground up, and build their own logic. Making this kind of videos, you are basically damaging young people wishing to become developers one day. For the devs out there trying to use your tutorials, it's all in fast forwarding the boring and not related parts. So, make up your mind. Teaching somebody to use Laravel or to be a PHP developer. Totally two different things.

Ответить
@mohammedghaithsaeed6884
@mohammedghaithsaeed6884 - 09.06.2017 16:19

really I do not have any Idie to say thank you
thank you for every word

Ответить
@stefan4800
@stefan4800 - 27.05.2017 18:26

Just use XAMPP! It's by far the easiest way!

Ответить
@dziugis8977
@dziugis8977 - 20.04.2017 11:40

For those who had an error: Syntax error or access violation: 1071
Go to app->Providers->AppServiceProvider.php in the AppServiceProved.php there is a method boot(), copy this in it and the error should be fixed: Schema::defaultStringLength(191);

Ответить
@Snip3rr
@Snip3rr - 11.04.2017 20:21

Thanks alot for all your videos!! You are really great at explaining things and managed to clarify alot of things in my head ( been learning web dev for a year and a half now and sometimes it gets overwhelming)

I got an error when trying the migrate command while exercising on this video, but i managed to fix it. So here's what to do if you get this error

$php artisan migrate

Migration table created successfully.

[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQ
L: alter table `users` add unique `users_email_unique`(`email`))

[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes.

- Go to [project]/app/Providers/AppServiceProvider.php
- Make sure you add use Illuminate\Support\Facades\Schema right after use Illuminate\Support\ServiceProvider;
- Add Schema::defaultStringLength(191); into the public function boot()

Now, if you already got the error, some of the tables might've been created. What I did was dropping those, and reused the php artisan migrate command and voila ! It all works perfectly

Ответить
@mauryareviews5654
@mauryareviews5654 - 03.04.2017 13:38

If You Are facing problem in laravel 5.4 , like Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes ,then Do this :
1.Go to AppServiceProvider.php , which is inside. App->Auth->Provider.
2.Then Add use Illuminate\Support\Facades\Schema; on Top
3.and inside Boot() add this , Schema::defaultStringLength(119);

Problem Solved

Ответить
@mauryareviews5654
@mauryareviews5654 - 03.04.2017 13:31

Error in lartavel 5.4 windows
: [Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

Solution : Check my below comment

Ответить
@mirozake
@mirozake - 30.03.2017 19:50

It was fun learning until I just hit this db errors. I can't seem to resolve it. Anyone want to help? I really want to be able to keep going :/ .. Error is long, and in two parts, in red box. First one: [illuminate/database/queryexception], SQLState[42501]: Base table or view already exists: 1050 users already exists. (Sql create table users 'id' int unassigned not null auto increment primary key, 'name' varcar 255.... etc... Second red box: [PDO Exception] , [SQLstate[42501]; Base table or view already exiss. 1050 users already exists. -- That's what it says. And when I look at sequel pro I can see users and migrations but not the other two as you have here. Thanks!

Ответить