UUIDs (Universally Unique Id entifiers) ngamaxabiso angama-128-bit asetyenziswa kugcino lwedatha, phakathi kwezinye izinto, ukuchonga amangeniso etafile ngokukodwa. Zimelwe njengomtya wehexadecimal owahlulwe ngokwamaqela amahlanu ahlulwe ngamakhonkco (Umzekelo: 09fe49b3-4d2b-471c-ac04-36c9e706b85f
). Nantsi lapho ezininzi Iingxoxo malunga neenzuzo kunye nokungalunganga kwee-UUIDs kwiinkcukacha zolwazi - ziyimfuneko kwiinkqubo ezisasazwayo.
Kwii-microservices kunye nezicelo zokuhlala ezininzi, ngoko ke kufanelekile ukuqwalasela ukwazisa ii-UUIDs. Ukutshintshela kuhlobo lwedatha i-BigInteger ukuya kwi-UUID (i-UUID eyahlukileyo yenguqulo yesi-4 ukusuka kwi- RFC 4122 ingcaciso ) kwisikhokelo se-PHP I- Laravel yenziwa ngokukhawuleza: Okokuqala, sidala uphawu olutsha.:
2aa7136d977617159be1834eaf40e871
Emva koko songeza zonke iimodeli zethu:
2aa7136d977617159be1834eaf40e871
KwiLaravel 9⁺ oku kulula ngakumbi: apha sele sineempawu ze- HasUuids ezilungele ukusetyenziswa. Kungenjalo, isakhelo sikwabonelela ngenkxaso enxulumeneyo, kodwa kusekho uhlobo lwedatha olungaziwayo ULID , enokuba nomdla ngenxa yokufundwa nokuhleleka ngcono.
Inxalenye enzima kukufuduka kwedatha ekhoyo. Ngokuqikelelwayo umntu unokuqhubeka ngolu hlobo lulandelayo:
- Yongeza iikholamu ezintsha ze-UUID ezinamaxabiso angenanto kuzo zonke iitafile
(nganye isekwe kuzo zonke iikholamu eziphambili kunye nezangaphandle) - Bhala amaxabiso e-UUID kwimiqolo emitsha
(kunye nezitshixo eziphambili ezinyukayo kunye nezitshixo ezihlaziyiweyo zangaphandle) - Cima imiqolo yoqobo
- Thiya ngokutsha iikholamu ezintsha
Kukho imingeni emininzi apha: Inkqubo yokufuduka ithatha ixesha elide kwaye iikholomu ezintsha zongezwa ekupheleni kwetafile (isisombululo esinokwenzeka: iikholomu zokuphumla ). Indlela ethe ngqo ngakumbi kukuguqula iikholamu ngokuthe ngqo.
Ukuba ubeka loo nto PostgreSQL enye, unga (emva kogcino lwangaphambili, kunjalo) sebenzisa lo mbuzo ulandelayo, umzekelo (phambi kokuba unokucima zonke iitafile ozikhupheleyo kwi Z. 19
/31
buyisela, kunye nemithetho yakho ekhethekileyo kwi-Z. 37
/39
add) kwaye ikopishe yonke imibuzo eyenziwe kuyo:
2aa7136d977617159be1834eaf40e871
Ukuba ngoku uqhuba imibuzo eyenziweyo kunye, ufudukele kwisiseko sedatha ngexesha elifutshane. Ngelixa ii-UUIDs zenziwe ngolu hlobo zingahambelani neenkcukacha ze-v4, ngokwezichazi-magama zikwindlela efanayo namangeno angaphambili, azingqubani nee-UUID ezintsha (kwiqela lesi-3 kwi-v4 kusoloko kukho i- 4
, isoloko inye kulwahlulo olufudusiweyo 0
), okukwathetha ukuba ii-UUID ezintsha zihlala zikhulu kune-UUIDs efudukayo.
Emva koko kuyacetyiswa ukuba ucime zonke iicache zeLaravel (php artisan cache:clear && php artisan route:clear && php artisan config:clear && php artisan view:clear && composer dump-autoload && rm -rf bootstrap/cache/*/*
) kunye neeseshini eziqhuba (rm -f storage/framework/sessions/*
) ukukhupha. Ewe kunjalo, yonke into inokuphunyezwa ngaphakathi kokufuduka kweLaravel:
2aa7136d977617159be1834eaf40e871
Emva koguqulo umntu usebenzisa kufuduko lwexesha elizayo endaweni yoko bigIncrements
okanye. bigInteger
ngoko uuid
:
2aa7136d977617159be1834eaf40e871