No video

Laravel Migrations: 12 Useful Tips in 12 Minutes

  Рет қаралды 79,382

Laravel Daily

Laravel Daily

Күн бұрын

In this video, I decided to share less-known things I've learned about Laravel migrations while working with Laravel over the years.
- - - - -
Support the channel by checking out my products:
- My Laravel courses membership: laraveldaily.t...
- Laravel QuickAdminPanel: bit.ly/quickad...
- Livewire Kit Components: livewirekit.com
- - - - -
Other places to follow:
- My weekly Laravel newsletter: bit.ly/laravel-...
- My personal Twitter: / povilaskorop

Пікірлер: 105
@mabdullahsari
@mabdullahsari 3 жыл бұрын
00:10 - Foreign Keys in Laravel 7 and below 01:35 - constrained() and nullable() 02:15 - Delete Parent: Restrict or Cascade? 04:10 - Change Order of Migrations 05:05 - What Migrations Have (not) Run? 05:40 - Timestamps with Default Value 06:23 - Customize Default Migration File 07:28 - Export Migrations into One SQL File 08:38 - Drop Multiple Columns 09:05 - Rollback or Refresh X Steps 09:57 - Auto-increment starting value 10:45 - Make Migration: Spaces vs Underscores
@adebajooluwaseyi2124
@adebajooluwaseyi2124 3 жыл бұрын
You keep producing videos that are worthy of Oscar Award every time. Man! You are the real deal
@CODINGISEASY
@CODINGISEASY 3 жыл бұрын
agree
@christopherokonkwo
@christopherokonkwo 3 жыл бұрын
Very clean and clear. What I love most about your videos is that that theirs no ambiguity at all. You're the best.👍
@redamakarem3737
@redamakarem3737 3 жыл бұрын
You are a gem in the Laravel community Respect
@YousefAltafWasti
@YousefAltafWasti 6 ай бұрын
Thanks, I have learned new tricks I didn't know about.
@peterf983
@peterf983 Жыл бұрын
Short tip and I know soft delete exist. Thanks!
@user-pu8ek9xr2w
@user-pu8ek9xr2w 3 жыл бұрын
Another thing that may be helpfull - add unique number for migration class and name: php artisan make:migration users_fix_`date +%N` this will add nanoseconds value to migration name and class name making it abolutly unique. Work in unix systems only.
@ivan_adamovich
@ivan_adamovich 3 жыл бұрын
You are the best teacher of Laravel, Thank you!
@peterson.associates
@peterson.associates 3 жыл бұрын
Thank you so much for contributing to the Laravel community! It's high quality content, well spoken, and I quite enjoy the topic as well. Farewell!
@gfonsecap
@gfonsecap 2 жыл бұрын
You can also use camelCase on migrations and it will add _ and lowercase letter on each capital... I think that's even faster
3 жыл бұрын
01:35 I learnt it the hard way. Edit: Thanks, I learned a lot!
@mariopproenca
@mariopproenca 3 жыл бұрын
Thank you for sharing these tips! Your channel videos are simply amazing, simple, extremely useful, and inspiring.
@AARP41298
@AARP41298 2 жыл бұрын
im happy that i use the same rename method to change the order of migration and i dont have evern 1 year of laravel experience
@cobratst
@cobratst 3 жыл бұрын
great content also for migration names you can use: php artisan make:migration AddFieldsToUsersTable and it will add underscores
@mitchierichie
@mitchierichie 3 жыл бұрын
Your videos are always worth watching. Thank you.
@breakinant
@breakinant 3 жыл бұрын
Your videos are so helpful and I'm learning so much from them, thanks a lot!
@MaximilianoBernasconi
@MaximilianoBernasconi 2 жыл бұрын
😍 i realy love your tips , and hope to be able to pay some day for those courses , tyvm for all the hard work
@Somcoders
@Somcoders 3 жыл бұрын
Another usefull video , Thank You!
@CODINGISEASY
@CODINGISEASY 3 жыл бұрын
*Nice tips I learned a few things, thanks!*
@marcelodheni
@marcelodheni 3 жыл бұрын
Great content, tyvm.
@abrahamnzau254
@abrahamnzau254 2 жыл бұрын
Very Informative 👏👏
@cuttysauce
@cuttysauce 2 жыл бұрын
Great video. Thanks!
@learncodeinbangla9181
@learncodeinbangla9181 3 жыл бұрын
Awesome teaching
@coder236
@coder236 3 жыл бұрын
Incredible tutorials, thankyou so much.
@shasimshahzad
@shasimshahzad 3 жыл бұрын
Very useful, as always. Thank you very much!
@Jameskaguo
@Jameskaguo 3 жыл бұрын
you are the best
@shokhzodnematov3840
@shokhzodnematov3840 3 жыл бұрын
fine
@AbdelrahmanEl.Monshed
@AbdelrahmanEl.Monshed 2 жыл бұрын
really appropriate thanks
@simon_leen
@simon_leen 3 жыл бұрын
Great content as always
@amirulnaim4747
@amirulnaim4747 3 жыл бұрын
Great sharing, thanks!
@user-ed7wi6xn5n
@user-ed7wi6xn5n 3 жыл бұрын
I would additionaly tell about "--table" and "--create" parameters in php "artisan make:migration". And maybe "php artisan make:model SomeModel -m"
@vladyslavbondarenko4983
@vladyslavbondarenko4983 3 жыл бұрын
Thanks! Very useful tips!
@bumblebity2902
@bumblebity2902 3 жыл бұрын
Sir, your forgotten one of most typical Junior developer mistakes, they do any migration mutations in existing migration files, although they must do in seperate files.
@rodglennrojas3067
@rodglennrojas3067 3 жыл бұрын
any video for this?
@loukiidris7033
@loukiidris7033 3 жыл бұрын
thank you so much your tutoreil it's very helpful
@ziyad_adel
@ziyad_adel 3 жыл бұрын
Love you so much sir ❤️❤️
@MJacksi
@MJacksi 2 жыл бұрын
Thank you!
@nicolas.chauvet
@nicolas.chauvet 3 жыл бұрын
10:25 "Six million dollar man" mode
@abelenocrodriguez
@abelenocrodriguez 3 жыл бұрын
Awesome, Very Useful!
@ArunKumar-kb1bb
@ArunKumar-kb1bb 3 жыл бұрын
Very helpful. Thanks
@codewithtee
@codewithtee 3 жыл бұрын
Thanks for another one 😊
@maysonhori
@maysonhori 3 жыл бұрын
Man, i love you! serious
@dhanushkafernando6316
@dhanushkafernando6316 3 жыл бұрын
Thank you povilas
@nclsv
@nclsv 2 жыл бұрын
More of these tips 👍
@diatm1506
@diatm1506 2 жыл бұрын
Thank Sir
@ThibautLefebvre
@ThibautLefebvre 3 жыл бұрын
I love your channel :)
@tarikmanoar
@tarikmanoar 3 жыл бұрын
Thanks a lot It help me lot
@imamhsn195
@imamhsn195 3 жыл бұрын
Thanks you Sir for the awsome tips. I have a question on staps. In migrations sometimes we create for adding or removing colums or other, so at that time we dont need softDeletes is there any option to avoid softDeletes of other custom fields when we creating migration for columns?
@salimedia33
@salimedia33 3 жыл бұрын
Very helpful 👍😍
@rambo_wagon
@rambo_wagon 3 жыл бұрын
This is excellent
@atikpatwary4584
@atikpatwary4584 3 жыл бұрын
dear sir, will you create a tutorial about Alibaba E-commerce website API integration ?
@dbelyaev
@dbelyaev 3 жыл бұрын
Dear Povilas! Do you have Laravel lessons series about scaling? For example, if you're doing complex social network (like KZbin clone), how to scale it infinitely?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Hi, scaling is a very very individual thing, depending on the project and actual problems to solve: is it a DB issue? is it a Laravel code optimization issue? is it just adding more servers? etc. So it's very hard to create any kind of "definite" lessons on this topic. Maybe in the future I will come up with something.
3 жыл бұрын
Great content, 1 question, should I use key type based on the project size, like integer for small and big integer for larger project... or use biginteger everywhere like default. Is it worth trading some performance for faster coding
@xuandungho
@xuandungho 3 жыл бұрын
Thanks you !
@mohamednabih6036
@mohamednabih6036 3 жыл бұрын
Thanks
@sombiri9147
@sombiri9147 3 жыл бұрын
wow, great!!!
@mannusaraswat3864
@mannusaraswat3864 3 жыл бұрын
Great tips ...
@paweu1660
@paweu1660 3 жыл бұрын
Please turn on the subtitles
@coolcha
@coolcha 3 жыл бұрын
Thank you for this video. I know you have covered this elsewhere, but I can't recall - how do you add foreign keys to existing columns. For e.g. I have a table which is like user_id but I did not mention it was a foreign key at first. Is there a way to retroactively add that in?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
You can create a new migration file and add $table->foreign('user_id')->references('id')->on('users'); But you need to make sure that current data does not violate that constrain, that there's no record with non-existing user_id.
@coolcha
@coolcha 3 жыл бұрын
@@LaravelDaily So nullable cannot be applied in this way?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
@@coolcha It can be applied, but if you already have values that don't have corresponding parent values, then nullable won't help.
@coolcha
@coolcha 3 жыл бұрын
@@LaravelDaily I see. Thank you for all your guidance and help.
@Stoney_Eagle
@Stoney_Eagle 3 жыл бұрын
Foreign constraints give me headaches 🤯 I collect data from the movie db api and EVERY key value can be missing... I had every record linked to a parent... Took me ages to get right. I had to remove ALL the constraints for seasons because many TV shows fails the queue job. At least I still have the TV constraint to remove everything belonging to that 😖
@Hoobeal
@Hoobeal 3 жыл бұрын
Hello, what is the extension to be able to visualize in the code if it is a table or a column? thanks for your tutorials!
@algeriennesaffaires7017
@algeriennesaffaires7017 3 жыл бұрын
Can you do a video updating Laravel 7 to 8
@IvanFirestone
@IvanFirestone 2 жыл бұрын
Which IDE are you using? And what’ extension?
@chirengito
@chirengito 3 жыл бұрын
nice job new abonnée
@sajjadboodaghi9638
@sajjadboodaghi9638 2 жыл бұрын
Great
@muhammadmuneeb4122
@muhammadmuneeb4122 3 жыл бұрын
If i want to change the column type, like string to datetimes from my database table, what is the best solution for this?
@alila3883
@alila3883 3 жыл бұрын
fantastic
@hamzashan8349
@hamzashan8349 3 жыл бұрын
Can u make video on localization for both vuejs and blades files for multi language vue application which is also running with blades features .
@LaravelDaily
@LaravelDaily 3 жыл бұрын
This is how we use it: kzbin.info/www/bejne/porXq4uGp86agac
@web2works
@web2works 3 жыл бұрын
Surpise there's no mention of $table->foreignIdFor($model)
@LaravelDaily
@LaravelDaily 3 жыл бұрын
It's not really widely used, even Taylor mentioned once on Twitter that he's not a fan of it, because model may change and then it breaks.
@cecilaw5504
@cecilaw5504 3 жыл бұрын
When to use constrained() on a foreign key?🤔
@cardboarddignity
@cardboarddignity 2 жыл бұрын
I am not fan of saving few milliseconds while not typing the underscore, but I'm a fan of not breaking my fingers, since for some reason I find it kinda difficult to type underscore with one hand :/
@abdqz5370
@abdqz5370 3 жыл бұрын
sry to bother you my master teacher i have a question when i write the following command $table->foreignid('table_name')->constrained('table_name'); should i put it right after the foreign key table or in the primary key migration file if the first, how can i tell the laravel which primary key from which table to constrain ? laravel 8 version thanks in advanced .....
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Not sure I understand your question, please read the official documentation laravel.com/docs/8.x/migrations#foreign-key-constraints
@Shez-dc3fn
@Shez-dc3fn 3 жыл бұрын
i hate timestamps.. because? there is a limit i found out that in mysql at least timestamp() will stop working from year 2038 or something... so maybe your system/app wont be around but w/e..
@sicknastydabdab2711
@sicknastydabdab2711 3 жыл бұрын
i love you
@burnt3436
@burnt3436 3 жыл бұрын
Is there a way to do a cascading soft delete?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Yes. Here's my article: blog.quickadminpanel.com/one-to-many-with-soft-deletes-deleting-parent-restrict-or-cascade/
@boredom509
@boredom509 2 жыл бұрын
Can you help me, when i do the 'php artisan migrate' it doesn't migrate any file from database/migrations. And when i check at my database there are only Migrations table created in it. I tried the migrate:rollback but it show 'nothing to rollback', i tried the php artisan migrate again and again but it just showing 'nothing to migrate'
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Maybe you have put migrations innwrong folder? Or maybe you've called the classes/methods in nonstandard way so Laravel doesnt recognize them?
@boredom509
@boredom509 2 жыл бұрын
@@LaravelDaily I dont think so because i just created this new project and follow a tutorial from the beginning, and their migration works but mine dont.
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Sorry, I can't debug it for you.
@boredom509
@boredom509 2 жыл бұрын
@@LaravelDailyIt's okay, Thanks for replying🙏🏾
@chandraauliatama6384
@chandraauliatama6384 2 жыл бұрын
can we export migration and seeder into one sql file?
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Yes, but not from Laravel, from your database client Export function.
@yetimtade5816
@yetimtade5816 3 жыл бұрын
Can u make video laravel-websockets
@LaravelDaily
@LaravelDaily 3 жыл бұрын
I don't work with websockets currently, so can't make a video about it.
@user-mx7mc7sv2q
@user-mx7mc7sv2q 3 жыл бұрын
How come that I get to know new things even though I'm from Symfony camp? O_o
@santhoshkumar-sf4bc
@santhoshkumar-sf4bc 3 жыл бұрын
will we lost data by rollback sir??
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Yes if you delete the table/columns on rollback
@santhoshkumar-sf4bc
@santhoshkumar-sf4bc 3 жыл бұрын
@@LaravelDaily how to update migration files... like Add columns or modify datatypes without loss table data sir??
@eas7112
@eas7112 3 жыл бұрын
can you make a video with use withMax() on pivot table price column?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Good suggestion, will do.
@eas7112
@eas7112 3 жыл бұрын
@@LaravelDaily ok thankyou, all i know withMax() is can't used on pivot table, i tired use user_id | project_id | rating User::withMax('projects', 'project_user.rating') it seems work, but the sql look weird ;( and also tired create a new model method user hasMany project relate to the pivot table, user_id | project_id | rating just don't know any better way to do this
@GergelyCsermely
@GergelyCsermely 3 жыл бұрын
Thanks
@firdavs.ibodullayev
@firdavs.ibodullayev 2 жыл бұрын
Great
Eloquent Performance: TOP 3 Mistakes Developers Make
7:59
Laravel Daily
Рет қаралды 48 М.
Fortunately, Ultraman protects me  #shorts #ultraman #ultramantiga #liveaction
00:10
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 18 МЛН
Logo Matching Challenge with Alfredo Larin Family! 👍
00:36
BigSchool
Рет қаралды 21 МЛН
I forced EVERYONE to use Linux
22:59
NetworkChuck
Рет қаралды 406 М.
Laravel Validation: 12 Less-Known Tips in 13 Minutes
13:11
Laravel Daily
Рет қаралды 38 М.
The Story of Next.js
12:13
uidotdev
Рет қаралды 564 М.
The Greenwich Meridian is in the wrong place
25:07
Stand-up Maths
Рет қаралды 794 М.
Laravel Security: Top 7 Mistakes Developers Make
11:16
Laravel Daily
Рет қаралды 83 М.
These CSS PRO Tips & Tricks Will Blow Your Mind!
8:48
Coding2GO
Рет қаралды 238 М.
How This New Battery is Changing the Game
12:07
Undecided with Matt Ferrell
Рет қаралды 184 М.
Generics: The most intimidating TypeScript feature
18:19
Matt Pocock
Рет қаралды 172 М.
Junior Code Review: Cleaning Up Laravel CRUD
14:54
Laravel Daily
Рет қаралды 68 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 145 М.
Fortunately, Ultraman protects me  #shorts #ultraman #ultramantiga #liveaction
00:10