Yuav ua li cas kuv rollback hauv laravel?
Yuav ua li cas kuv rollback hauv laravel?

Video: Yuav ua li cas kuv rollback hauv laravel?

Video: Yuav ua li cas kuv rollback hauv laravel?
Video: UA KAWG PEEV XWM -May maylee [official] New Song/MV/VDO 2024, Kaum ib hlis
Anonim

Hloov tus lej batch ntawm kev tsiv teb tsaws koj xav tau rov qab mus rau qhov siab tshaj. Khiav migrate: 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.

Yog li ntawd, yuav ua li cas kuv tsiv teb tsaws hauv laravel?

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.

Ib tug kuj yuav nug, kev tsiv teb tsaws thiab kev cog qoob loo yog dab tsi? Taw qhia Migration thiab Seeding Kev tsiv teb tsaws yog zoo li kev tswj hwm version rau koj cov ntaub ntawv, tso cai rau koj pab neeg kom hloov kho tau yooj yim thiab sib qhia daim ntawv thov cov ntaub ntawv schema. Kev tsiv teb tsaws yog feem ntau ua ke nrog Laravel's schema builder kom yooj yim tsim koj daim ntawv thov database schema.

Ib yam li ntawd, nws raug nug, Kuv yuav ua li cas thiaj li khiav tau ib qho seeder tshwj xeeb hauv laravel?

A noob chav kawm tsuas muaj ib txoj hauv kev los ntawm lub neej ntawd: khiav . Txoj kev no yog hu ua thaum db: noob Artisan hais kom ua. Hauv lub khiav txoj kev, koj tuaj yeem ntxig cov ntaub ntawv rau hauv koj lub database txawm li cas los xij koj xav tau. Koj tuaj yeem siv tus tsim cov lus nug los ntxig cov ntaub ntawv los yog koj tuaj yeem siv Eloquent qauv factories.

Kuv yuav khiav lub Hoobkas hauv laravel li cas?

Txhawm rau siv qhov tau hais tseg Hoobkas (xws li los ntawm koj qhov kev sim lossis cov noob), peb siv cov Hoobkas muaj nuj nqi muab los ntawm laravel . // tsim ib tus neeg siv thiab khaws cia rau hauv database $user = Hoobkas (AppUser::class)->create(); Qhov no tsim ib tus neeg siv. Txhawm rau tsim ntau tus neeg siv - tsuas yog dhau qhov ntsuas thib ob mus rau qhov Hoobkas muaj nuj nqi.

Pom zoo: