Laravel migration ua haujlwm li cas?
Laravel migration ua haujlwm li cas?

Video: Laravel migration ua haujlwm li cas?

Video: Laravel migration ua haujlwm li cas?
Video: Опции Laravel make:migration 2024, Kaum ib hlis
Anonim

3 Teb. Kev tsiv teb tsaws chaw yog hom kev tswj hwm version rau koj cov ntaub ntawv. Lawv tso cai rau ib pab neeg los hloov kho cov ntaub ntawv schema thiab nyob twj ywm rau ntawm lub xeev schema tam sim no. Kev tsiv teb tsaws chaw feem ntau ua ke nrog Schema Builder kom yooj yim tswj koj daim ntawv thov schema.

Ntawm no, dab tsi yog kev siv migration hauv laravel?

Tsuas tso tseg, Laravel migration yog ib txoj hauv kev uas tso cai rau koj los tsim ib lub rooj hauv koj cov ntaub ntawv, tsis tas yuav mus rau tus thawj tswj hwm database xws li phpmyadmin lossis sql lite lossis txawm tias koj tus thawj tswj hwm yog dab tsi.

Qhov thib ob, kuv yuav tsiv teb tsaws hauv laravel li cas? Rau tsim a kev tsiv teb tsaws chaw , siv cov ua : kev tsiv teb tsaws chaw Artisan command: Thaum koj tsim a kev tsiv teb tsaws chaw ntaub ntawv, Laravel khaws nws hauv /database/migrations directory. Txhua kev tsiv teb tsaws chaw cov ntaub ntawv npe muaj lub sij hawm uas tso cai Laravel los txiav txim qhov kev txiav txim ntawm kev tsiv teb tsaws.

Ua li no, kev tsiv teb tsaws hauv laravel yog dab tsi?

Artisan thiab Laravel Kev tsiv teb tsaws chaw. Hauv ntej, kev tsiv teb tsaws yog cov ntaub ntawv uas muaj cov ntsiab lus hauv chav kawm nrog ob qho tib si up() thiab down() txoj kev. Txoj kev up() khiav thaum lub kev tsiv teb tsaws chaw yog executed los hloov cov ntaub ntawv. Txoj kev down() yog khiav los thim cov kev hloov pauv.

Kuv yuav ua li cas rollback ib qho kev tsiv teb tsaws chaw hauv laravel?

Hloov tus lej batch ntawm tus kev tsiv teb tsaws chaw koj xav tau rov qab mus rau qhov siab tshaj. Khiav tsiv teb tsaws : rov qab.

  1. Mus rau DB thiab rho tawm / hloov npe nkag nkag rau koj qhov tshwj xeeb-migration.
  2. Tso lub rooj tsim los ntawm koj qhov tshwj xeeb-migration.
  3. Khiav php artisan migrate --path=/database/migrations/your-specific-migration. php ib.

Pom zoo: