{"id":322610,"date":"2021-05-05T15:00:06","date_gmt":"2021-05-05T15:00:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=322610"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=322610","title":{"rendered":"\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 SQL \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043d\u0430 PHP"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041d\u0435 \u043f\u0438\u0441\u0430\u043b \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0435\u0449\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u043c\u044b\u0441\u043b\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0441\u0432\u043e\u0438\u0445 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u044d\u0442\u043e, \u0442\u043e \u0431\u044b\u043b\u043e \u0432\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a&#8230; \u041c\u043d\u043e\u0433\u043e \u043f\u0438\u0441\u0430\u043b \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u043b \u043f\u0441\u0435\u0432\u0434\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0430\u0442\u044b\u043a\u0430\u043b\u0441\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0443\u0436\u0430\u0441\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0443\u0436\u0430\u0441\u043d\u043e \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e. \u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 &#171;\u0443\u0434\u043e\u0431\u043d\u044b\u0435&#187; \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0441\u0442\u0430\u043b\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e&#8230; \u041a\u043e\u0440\u043e\u0447\u0435, \u0440\u0443\u043a\u0438 \u043d\u0435 \u0438\u0437 \u0442\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430, \u0433\u043e\u043b\u043e\u0432\u0430 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0430\u043c\u0431\u0438\u0446\u0438\u043e\u0437\u043d\u0430\u044f&#8230; \u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u044f \u0434\u043e\u0448\u0435\u043b \u0434\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u044b\u0441\u043b\u0438: &#171;\u041d\u0430\u0434\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 GitHub \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432&#187;&#8230; \u0412\u0441\u0435 \u0448\u043b\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0434\u043e\u0448\u0435\u043b \u044f \u0434\u043e \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0447\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c&#8230; \u0412 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0448\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438. \u0418 \u0432\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e <a href=\"https:\/\/github.com\/mepihindeveloper\/php-sql-migration\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 SQL \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439<\/a> \u0432 \u0442\u043e\u043c \u043a\u043b\u044e\u0447\u0435, \u043a\u0430\u043a \u044f \u0435\u0433\u043e \u0432\u0438\u0436\u0443.<\/p>\n<p>\u0418 \u0442\u0430\u043a, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u0433, \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b, \u0447\u0442\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u0443\u0436\u0430\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0430\u043a\u0442\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u043f\u0430\u043f\u043a\u0438 \u0438 \u043f\u0440\u043e\u0447\u0435\u043c\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443 \u0432\u0441\u0435\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0442\u0430\u043c \u0435\u0449\u0435 \u0434\u043b\u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u0442\u0430\u043c&#8230;<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u044f \u043c\u043e\u0433\u0443 \u043e\u0448\u0438\u0431\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u043b\u0438\u0447\u043d\u043e \u044f \u0443\u0432\u0435\u0440\u0435\u043d \u0434\u043b\u044f \u0441\u0435\u0431\u044f, \u0447\u0442\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f SQL \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 git \u0438\u043b\u0438 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 init \u0444\u0430\u0439\u043b, \u043a\u0430\u043a \u044d\u0442\u043e \u0435\u0441\u0442\u044c \u0432 Yii2.<\/p>\n<p><strong>\u0418\u0434\u0435\u044f<\/strong><\/p>\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f SQL \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0432\u043e\u0435\u043c 2 SQL \u0444\u0430\u0439\u043b\u0430. \u0414\u0430, \u0432\u043e\u0442 \u0442\u0443\u0442 \u0441\u0435\u0439\u0447\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0448\u043a\u0432\u0430\u043b \u043a\u0440\u0438\u0442\u0438\u043a\u0438 \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u0430 \u0438 \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u043d\u043e \u0441\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0447\u0442\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043c\u044b \u043e\u0442 SQLBuilder \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043d\u0430 \u0447\u0438\u0441\u0442\u044b\u0439 SQL, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 IDE \u043c\u043e\u0436\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c DDL \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u0432\u043e\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u043d\u0430\u0434\u043e \u0432\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0442\u043e-\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u0438\u043b\u0434\u0435\u0440\u043e\u043c, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SQL \u0447\u0438\u0441\u0442\u044b\u0439 \u0432 \u0442\u043e\u043c \u0436\u0435 \u0431\u0438\u043b\u0434\u0435\u0440\u0435, \u0430 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u044d\u0442\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0432\u043f\u0435\u0440\u0435\u043c\u0435\u0448\u043a\u0443&#8230; \u041a\u043e\u0440\u043e\u0447\u0435, \u0442\u0443\u0442 \u044f \u043f\u043e\u043d\u044f\u043b \u0438 \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0432 \u043c\u043e\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u0446\u0435\u043b\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0432\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c, \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e SQL \u043a\u043e\u0434.<\/p>\n<p>\u0421\u0443\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430: \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f, \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0442\u0443\u0434\u0430 \u043a\u043e\u0434 UP \u0438 DOWN, \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u0438\u043b\u0438 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435. \u0412\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430.<\/p>\n<p><strong>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430<\/strong><\/p>\n<p>\u0412 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441&nbsp;<code>SqlMigration<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u044e\u0431\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0434\u043b\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u0434.<\/p>\n<p>\u041a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0431\u044b\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043a\u043b\u0430\u0441\u0441&nbsp;<code>ConsoleSqlMigration<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442&nbsp;<code>SqlMigration<\/code>&nbsp;\u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b. \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442&nbsp;<code>parent::<\/code>&nbsp;\u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u0432\u044b\u0432\u043e\u0434\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c (\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b).<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441&nbsp;<code>DatabaseInterface<\/code>&nbsp;\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a. \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p><strong>schema<\/strong>&nbsp;&#8212; \u0441\u0445\u0435\u043c\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439<\/p>\n<\/li>\n<li>\n<p><strong>table<\/strong>&nbsp;&#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439<\/p>\n<\/li>\n<li>\n<p><strong>path<\/strong>&nbsp;&#8212; \u043f\u0443\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u043b\u044f \u043f\u0430\u043f\u043a\u0438 \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 (\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435) \u0441\u0445\u0435\u043c\u044b, \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u0430\u043f\u043a\u0438 \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 (\u043f\u0440\u0430\u0432). \u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u043d\u0435\u0439.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <code>SqlMigration<\/code> \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u043b\u0430\u0441\u0441 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432, \u043d\u043e \u043c\u0430\u043b\u043e \u043b\u0438 \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443. \u0412 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432:<\/p>\n<ol>\n<li>\n<p><code>public function up(int $count = 0): array;<\/code><\/p>\n<\/li>\n<li>\n<p><code>public function down(int $count = 0): array;<\/code><\/p>\n<\/li>\n<li>\n<p><code>public function history(int $limit = 0): array;<\/code><\/p>\n<\/li>\n<li>\n<p><code>public function create(string $name): bool;<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0430\u043c\u0438 \u0437\u0430 \u0441\u0435\u0431\u044f \u0433\u043e\u0432\u043e\u0440\u044f\u0442. \u041d\u043e \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0443\u043a\u0430\u0436\u0443 \u0442\u0443\u0442 \u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438\u0437 PHPDoc:<\/p>\n<pre><code class=\"php\">\/** \t * \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \t * \t * @param int $count \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f (0 - \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435\u0445) \t * \t * @return array \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439. \u0421\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434: \t * 1. \u0421\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \t * 2. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \t * [ \t *  'success' =&gt; [...], \t *  'error' =&gt; [...] \t * ] \t * \u041a\u043b\u044e\u0447 error \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. \t * \t * @throws SqlMigrationException \t *\/ \tpublic function up(int $count = 0): array; \t \t\/** \t * \u041e\u0442\u043c\u0435\u043d\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \t * \t * @param int $count \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f (0 - \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435\u0445) \t * \t * @return array \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0442\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439. \u0421\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434: \t * 1. \u0421\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \t * 2. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \t * [ \t *  'success' =&gt; [...], \t *  'error' =&gt; [...] \t * ] \t * \u041a\u043b\u044e\u0447 error \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. \t * \t * @throws SqlMigrationException \t *\/ \tpublic function down(int $count = 0): array; \t \t\/** \t * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \t * \t * @param int $limit \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0441\u043f\u0438\u0441\u043a\u0430 (null - \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a) \t * \t * @return array \t *\/ \tpublic function history(int $limit = 0): array; \t \t\/** \t * \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \t * \t * @param string $name \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \t * \t * @return bool \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0435\u0441\u043b\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0430. \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \t * \t * @throws RuntimeException|SqlMigrationException \t *\/ \tpublic function create(string $name): bool;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <code>SqlMigration<\/code>. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u042d\u0442\u043e \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"php\">\/**  * \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438  *\/ public const UP = 'up'; public const DOWN = 'down';<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0443\u0436\u0435\u043d \u043c\u0430\u0441\u0441\u0438\u0432 \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0439 <a href=\"https:\/\/github.com\/mepihindeveloper\/php-database\/blob\/stable\/src\/interfaces\/DatabaseInterface.php\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/a> <code>DatabaseInterface<\/code>. \u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 (DI) \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a:<\/p>\n<pre><code class=\"php\">\/**  * SqlMigration constructor.  *  * @param DatabaseInterface $database \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445  * @param array $settings \u041c\u0430\u0441\u0441\u0438\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a  *  * @throws SqlMigrationException  *\/ public function __construct(DatabaseInterface $database, array $settings) { \t$this-&gt;database = $database; \t$this-&gt;settings = $settings; \t \tforeach (['schema', 'table', 'path'] as $settingsKey) { \t\tif (!array_key_exists($settingsKey, $settings)) { \t\t\tthrow new SqlMigrationException(\"\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 {$settingsKey} \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a.\"); \t\t} \t} }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u044b\u0435 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442. \u041c\u0435\u0442\u043e\u0434 \u0432\u0435\u0440\u043d\u0443\u0442 <code>bool<\/code> \u0435\u0441\u043b\u0438 \u0441\u0445\u0435\u043c\u0430 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0438 \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"php\">\/**  * \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0445\u0435\u043c\u0443 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f  *  * @return bool \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0435\u0441\u043b\u0438 \u0441\u0445\u0435\u043c\u0430 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442  * \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435  *  * @throws SqlMigrationException  *\/ public function initSchemaAndTable(): bool { \t$schemaSql = &lt;&lt;&lt;SQL \t\tCREATE SCHEMA IF NOT EXISTS {$this-&gt;settings['schema']}; \tSQL; \t \tif (!$this-&gt;database-&gt;execute($schemaSql)) { \t\tthrow new SqlMigrationException('\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438'); \t} \t \t$tableSql = &lt;&lt;&lt;SQL \t\tCREATE TABLE IF NOT EXISTS {$this-&gt;settings['schema']}.{$this-&gt;settings['table']} ( \t\t\t\"name\" varchar(180) COLLATE \"default\" NOT NULL, \t\t\tapply_time int4, \t\t\tCONSTRAINT {$this-&gt;settings['table']}_pk PRIMARY KEY (\"name\") \t\t) WITH (OIDS=FALSE) \tSQL; \t \tif (!$this-&gt;database-&gt;execute($tableSql)) { \t\tthrow new SqlMigrationException('\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438'); \t} \t \treturn true; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438\u043c\u0435\u043d\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 (\u043f\u0430\u043f\u043a\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438):<\/p>\n<pre><code class=\"php\">\/**  * \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0438\u043c\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c  *  * @param string $name \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438  *  * @throws SqlMigrationException  *\/ protected function validateName(string $name): void { \tif (!preg_match('\/^[\\w]+$\/', $name)) { \t\tthrow new SqlMigrationException('\u0418\u043c\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u043a\u0432\u044b, \u0446\u0438\u0444\u0440\u044b \u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u044f.'); \t} }  \/**  * \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0438\u043c\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443: m{\u0434\u0430\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Ymd_His}_name  *  * @param string $name \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438  *  * @return string  *\/ protected function generateName(string $name): string { \treturn 'm' . gmdate('Ymd_His') . \"_{$name}\"; }<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0430\u043f\u043a\u0438 \u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043d\u0435\u0439. \u041f\u0430\u043f\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0438\u043c\u0435\u043d\u0438: m_\u0434\u0430\u0442\u0430_\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435_\u0438\u043c\u044f &#8212; \u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u0443\u043a\u0432\u044b, \u0446\u0438\u0444\u0440\u044b \u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"php\">\/**  * @inheritDoc  *  * @throws RuntimeException|SqlMigrationException  *\/ public function create(string $name): bool { \t$this-&gt;validateName($name); \t \t$migrationMame = $this-&gt;generateName($name); \t$path = \"{$this-&gt;settings['path']}\/{$migrationMame}\"; \t \tif (!mkdir($path, 0775, true) &amp;&amp; !is_dir($path)) { \t\tthrow new RuntimeException(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. \u0414\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f {$path}\u043d\u0435 \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430\"); \t} \t \tif (file_put_contents($path . '\/up.sql', '') === false) { \t\tthrow new RuntimeException(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 {$path}\/up.sql\"); \t} \t \tif (!file_put_contents($path . '\/down.sql', '') === false) { \t\tthrow new RuntimeException(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 {$path}\/down.sql\"); \t} \t \treturn true; }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439, \u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439:<\/p>\n<pre><code class=\"php\">\/**  * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439  *  * @param int $limit \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0441\u043f\u0438\u0441\u043a\u0430 (null - \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a)  *  * @return array  *\/ protected function getHistoryList(int $limit = 0): array { \t$limitSql = $limit === 0 ? '' : \"LIMIT {$limit}\"; \t$historySql = &lt;&lt;&lt;SQL \t\tSELECT \"name\", apply_time \t\tFROM {$this-&gt;settings['schema']}.{$this-&gt;settings['table']} \t\tORDER BY apply_time DESC, \"name\" DESC {$limitSql} \tSQL; \t \treturn $this-&gt;database-&gt;queryAll($historySql); }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439 \u043d\u0430 \u043d\u0435\u0433\u043e \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430:<\/p>\n<pre><code class=\"php\">\/**  * @inheritDoc  *\/ public function history(int $limit = 0): array { \t$historyList = $this-&gt;getHistoryList($limit); \t \tif (empty($historyList)) { \t\treturn ['\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043f\u0443\u0441\u0442\u0430']; \t} \t \t$messages = []; \t \tforeach ($historyList as $historyRow) { \t\t$messages[] = \"\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u044f {$historyRow['name']} \u043e\u0442 \" . date('Y-m-d H:i:s', $historyRow['apply_time']); \t} \t \treturn $messages; }<\/code><\/pre>\n<p>\u0422\u0430\u043a, \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0432 \u0411\u0414. \u042d\u0442\u043e \u043d\u0430\u0434\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0435 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u0438 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e.<\/p>\n<pre><code class=\"php\">\/**  * \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439  *  * @param string $name \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438  *  * @return bool \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0435\u0441\u043b\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0430 (\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439).  * \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.  *  * @throws SqlMigrationException  *\/ protected function addHistory(string $name): bool { \t$sql = &lt;&lt;&lt;SQL \t\tINSERT INTO {$this-&gt;settings['schema']}.{$this-&gt;settings['table']} (\"name\", apply_time) VALUES(:name, :apply_time); \tSQL; \t \tif (!$this-&gt;database-&gt;execute($sql, ['name' =&gt; $name, 'apply_time' =&gt; time()])) { \t\tthrow new SqlMigrationException(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f {$name}\"); \t} \t \treturn true; }  \/**  * \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439  *  * @param string $name \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438  *  * @return bool \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0435\u0441\u043b\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u043c\u0435\u043d\u0435\u043d\u0430 (\u0443\u0434\u0430\u043b\u0435\u043d\u0430 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439).  * \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.  *  * @throws SqlMigrationException  *\/ protected function removeHistory(string $name): bool { \t$sql = &lt;&lt;&lt;SQL \t\tDELETE FROM {$this-&gt;settings['schema']}.{$this-&gt;settings['table']} WHERE \"name\" = :name; \tSQL; \t \tif (!$this-&gt;database-&gt;execute($sql, ['name' =&gt; $name])) { \t\tthrow new SqlMigrationException(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043e\u0442\u043c\u0435\u043d\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 {$name}\"); \t} \t \treturn true; }<\/code><\/pre>\n<p>\u041d\u0443 \u0438 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0437\u0430\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u0441\u043f\u0438\u0441\u043a\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445, \u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439. \u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0411\u0414 \u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438.<\/p>\n<pre><code class=\"php\">\/**  * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439  *  * @return array  *\/ protected function getNotAppliedList(): array { \t$historyList = $this-&gt;getHistoryList(); \t$historyMap = []; \t \tforeach ($historyList as $item) { \t\t$historyMap[$item['name']] = true; \t} \t \t$notApplied = []; \t$directoryList = glob(\"{$this-&gt;settings['path']}\/m*_*_*\"); \t \tforeach ($directoryList as $directory) { \t\tif (!is_dir($directory)) { \t\t\tcontinue; \t\t} \t\t \t\t$directoryParts = explode('\/', $directory); \t\tpreg_match('\/^(m(\\d{8}_?\\d{6})\\D.*?)$\/is', end($directoryParts), $matches); \t\t$migrationName = $matches[1]; \t\t \t\tif (!isset($historyMap[$migrationName])) { \t\t\t$migrationDateTime = DateTime::createFromFormat('Ymd_His', $matches[2])-&gt;format('Y-m-d H:i:s'); \t\t\t$notApplied[] = [ \t\t\t\t'path' =&gt; $directory, \t\t\t\t'name' =&gt; $migrationName, \t\t\t\t'date_time' =&gt; $migrationDateTime \t\t\t]; \t\t} \t} \t \tksort($notApplied); \t \treturn $notApplied; }<\/code><\/pre>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0438 \u043e\u0442\u043a\u0430\u0442\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438: up \u0438 down. \u041d\u043e \u0442\u0443\u0442 \u0435\u0441\u0442\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u043d\u044e\u0430\u043d\u0441, up \u0438 down \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442  \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e. \u0422\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f (\u0435\u0441\u043b\u0438 \u043d\u0430\u0434\u043e) \u0438 \u0442\u0438\u043f (up\/down &#8212; \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435).<\/p>\n<pre><code class=\"php\">\/**  * \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438  *  * @param array $list \u041c\u0430\u0441\u0441\u0438\u0432 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439  * @param int $count \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f  * @param string $type \u0422\u0438\u043f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 (up\/down)  *  * @return array \u0421\u043f\u0438\u0441\u043e\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439  *  * @throws RuntimeException  *\/ protected function execute(array $list, int $count, string $type): array { \t$migrationInfo = []; \t \tfor ($index = 0; $index &lt; $count; $index++) { \t\t$migration = $list[$index]; \t\t$migration['path'] = array_key_exists('path', $migration) ? $migration['path'] : \t\t\t\"{$this-&gt;settings['path']}\/{$migration['name']}\"; \t\t$migrationContent = file_get_contents(\"{$migration['path']}\/{$type}.sql\"); \t\t \t\tif ($migrationContent === false) { \t\t\tthrow new RuntimeException('\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u043e\u0438\u0441\u043a\u0430\/\u0447\u0442\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438'); \t\t} \t\t \t\ttry { \t\t\tif (!empty($migrationContent)) { \t\t\t\t$this-&gt;database-&gt;beginTransaction(); \t\t\t\t$this-&gt;database-&gt;execute($migrationContent); \t\t\t\t$this-&gt;database-&gt;commit(); \t\t\t} \t\t\t \t\t\tif ($type === self::UP) { \t\t\t\t$this-&gt;addHistory($migration['name']); \t\t\t} else { \t\t\t\t$this-&gt;removeHistory($migration['name']); \t\t\t} \t\t\t \t\t\t$migrationInfo['success'][] = $migration; \t\t} catch (SqlMigrationException | PDOException $exception) { \t\t\t$migrationInfo['error'][] = array_merge($migration, ['errorMessage' =&gt; $exception-&gt;getMessage()]); \t\t\t \t\t\tbreak; \t\t} \t} \t \treturn $migrationInfo; }<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0434\u043e \u0436\u0443\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439:<\/p>\n<ol>\n<li>\n<p>\u0418\u0434\u0435\u0442 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0431\u0435\u0440\u0435\u043c \u0435\u0435 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u0434\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 $migration[&#8216;path&#8217;] = <code>array_key_exists('path', $migration) ? $migration['path'] : \"{$this-&gt;settings['path']}\/{$migration['name']}\";<\/code><\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c (\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u0432\u044b\u0448\u0435): <code>$migrationContent = file_get_contents(\"{$migration['path']}\/{$type}.sql\");<\/code><\/p>\n<\/li>\n<li>\n<p>\u0418 \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 UP &#8212; \u0434\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438, \u0430 \u0438\u043d\u0430\u0447\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0438\u0437 \u0438\u0441\u0442\u043e\u0440\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u043f\u0438\u0448\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u043c \u0438 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c (\u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u043d\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435 \u0443\u043f\u0430\u0434\u0435\u0442).<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c. \u041d\u0443 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u043f\u0438\u0448\u0435\u043c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 (\u043f\u043e\u0447\u0442\u0438) \u043c\u0435\u0442\u043e\u0434\u044b up \u0438 down:<\/p>\n<pre><code class=\"php\">\/**  * @inheritDoc  *\/ public function up(int $count = 0): array { \t$executeList = $this-&gt;getNotAppliedList(); \t \tif (empty($executeList)) { \t\treturn []; \t} \t \t$executeListCount = count($executeList); \t$executeCount = $count === 0 ? $executeListCount : min($count, $executeListCount); \t \treturn $this-&gt;execute($executeList, $executeCount, self::UP); }  \/**  * @inheritDoc  *\/ public function down(int $count = 0): array { \t$executeList = $this-&gt;getHistoryList(); \t \tif (empty($executeList)) { \t\treturn []; \t} \t \t$executeListCount = count($executeList); \t$executeCount = $count === 0 ? $executeListCount : min($count, $executeListCount); \t \treturn $this-&gt;execute($executeList, $executeCount, self::DOWN); }<\/code><\/pre>\n<p>\u0420\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0412\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0443\u0442 \u0432\u0441\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438. \u042d\u0442\u043e \u043d\u0430\u0434\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c, \u043a\u0430\u043a\u0438\u043c \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435. \u042d\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0430 \u043f\u043e\u0434\u043e\u0431\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b API \u043f\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0443 \u043e\u0442\u0432\u0435\u0442\u0430. \u0412\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u043b\u0435\u0435 \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0442\u0443\u0434\u0430:<\/p>\n<pre><code class=\"php\">&lt;?php  declare(strict_types = 1);  namespace mepihindeveloper\\components;  use mepihindeveloper\\components\\exceptions\\SqlMigrationException; use mepihindeveloper\\components\\interfaces\\DatabaseInterface; use RuntimeException;  \/**  * Class ConsoleSqlMigration  *  * \u041a\u043b\u0430\u0441\u0441 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 SQL \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c (\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b)  *  * @package mepihindeveloper\\components  *\/ class ConsoleSqlMigration extends SqlMigration { \t \tpublic function __construct(DatabaseInterface $database, array $settings) { \t\tparent::__construct($database, $settings); \t\t \t\ttry { \t\t\t$this-&gt;initSchemaAndTable(); \t\t\t \t\t\tConsole::writeLine('\u0421\u0445\u0435\u043c\u0430 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u044b', Console::FG_GREEN); \t\t} catch (SqlMigrationException $exception) { \t\t\tConsole::writeLine($exception-&gt;getMessage(), Console::FG_RED); \t\t\t \t\t\texit; \t\t} \t} \t \tpublic function up(int $count = 0): array { \t\t$migrations = parent::up($count); \t\t \t\tif (empty($migrations)) { \t\t\tConsole::writeLine(\"\u041d\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f\"); \t\t\t \t\t\texit; \t\t} \t\t \t\tforeach ($migrations['success'] as $successMigration) { \t\t\tConsole::writeLine(\"\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u044f {$successMigration['name']} \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0430\", Console::FG_GREEN); \t\t} \t\t \t\tif (array_key_exists('error', $migrations)) { \t\t\tforeach ($migrations['error'] as $errorMigration) { \t\t\t\tConsole::writeLine(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 {$errorMigration['name']}\", Console::FG_RED); \t\t\t} \t\t\t \t\t\texit; \t\t} \t\t \t\treturn $migrations; \t} \t \tpublic function down(int $count = 0): array { \t\t$migrations = parent::down($count); \t\t \t\tif (empty($migrations)) { \t\t\tConsole::writeLine(\"\u041d\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043e\u0442\u043c\u0435\u043d\u044b\"); \t\t\t \t\t\texit; \t\t} \t\t \t\tif (array_key_exists('error', $migrations)) { \t\t\tforeach ($migrations['error'] as $errorMigration) { \t\t\t\tConsole::writeLine(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043e\u0442\u043c\u0435\u043d\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 {$errorMigration['name']} : \" . \t\t\t\t\tPHP_EOL . \t\t\t\t\t$errorMigration['errorMessage'], \t\t\t\t\tConsole::FG_RED); \t\t\t} \t\t\t \t\t\texit; \t\t} \t\t \t\tforeach ($migrations['success'] as $successMigration) { \t\t\tConsole::writeLine(\"\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u044f {$successMigration['name']} \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u043c\u0435\u043d\u0435\u043d\u0430\", Console::FG_GREEN); \t\t} \t\t \t\treturn $migrations; \t} \t \tpublic function create(string $name): bool { \t\ttry { \t\t\tparent::create($name); \t\t\t \t\t\tConsole::writeLine(\"\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u044f {$name} \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0430\"); \t\t} catch (RuntimeException | SqlMigrationException $exception) { \t\t\tConsole::writeLine($exception-&gt;getMessage(), Console::FG_RED); \t\t\t \t\t\treturn false; \t\t} \t\t \t\treturn true; \t} \t \tpublic function history(int $limit = 0): array { \t\t$historyList = parent::history($limit); \t\t \t\tforeach ($historyList as $historyRow) { \t\t\tConsole::writeLine($historyRow); \t\t} \t\t \t\treturn $historyList; \t} }<\/code><\/pre>\n<p>\u0421\u043e\u0433\u043b\u0430\u0448\u0443\u0441\u044c, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u044b\u0448\u0435\u043b \u043d\u0435 \u043f\u0440\u044f\u043c \u0443\u0431\u043e\u0439\u043d\u044b\u0439 \u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e DI \u043a \u043d\u0435\u043c\u0443, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e. \u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 <a href=\"https:\/\/github.com\/mepihindeveloper\/php-sql-migration\" rel=\"noopener noreferrer nofollow\">GitHub<\/a> \u0438 \u0432 <a href=\"https:\/\/packagist.org\/packages\/mepihindeveloper\/php-sql-migration\" rel=\"noopener noreferrer nofollow\">Composer<\/a>.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/555982\/\"> https:\/\/habr.com\/ru\/post\/555982\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041d\u0435 \u043f\u0438\u0441\u0430\u043b \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0435\u0449\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u043c\u044b\u0441\u043b\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0441\u0432\u043e\u0438\u0445 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u044d\u0442\u043e, \u0442\u043e \u0431\u044b\u043b\u043e \u0432\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a&#8230; \u041c\u043d\u043e\u0433\u043e \u043f\u0438\u0441\u0430\u043b \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u043b \u043f\u0441\u0435\u0432\u0434\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0430\u0442\u044b\u043a\u0430\u043b\u0441\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0443\u0436\u0430\u0441\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0443\u0436\u0430\u0441\u043d\u043e \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e. \u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 &#171;\u0443\u0434\u043e\u0431\u043d\u044b\u0435&#187; \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0441\u0442\u0430\u043b\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e&#8230; \u041a\u043e\u0440\u043e\u0447\u0435, \u0440\u0443\u043a\u0438 \u043d\u0435 \u0438\u0437 \u0442\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430, \u0433\u043e\u043b\u043e\u0432\u0430 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0430\u043c\u0431\u0438\u0446\u0438\u043e\u0437\u043d\u0430\u044f&#8230; \u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u044f \u0434\u043e\u0448\u0435\u043b \u0434\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u044b\u0441\u043b\u0438: &#171;\u041d\u0430\u0434\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 GitHub \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432&#187;&#8230; \u0412\u0441\u0435 \u0448\u043b\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0434\u043e\u0448\u0435\u043b \u044f \u0434\u043e \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0447\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c&#8230; \u0412 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0448\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438. \u0418 \u0432\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e <a href=\"https:\/\/github.com\/mepihindeveloper\/php-sql-migration\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 SQL \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439<\/a> \u0432 \u0442\u043e\u043c \u043a\u043b\u044e\u0447\u0435, \u043a\u0430\u043a \u044f \u0435\u0433\u043e \u0432\u0438\u0436\u0443.<\/p>\n<p>\u0418 \u0442\u0430\u043a, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u0433, \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b, \u0447\u0442\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u0443\u0436\u0430\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0430\u043a\u0442\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u043f\u0430\u043f\u043a\u0438 \u0438 \u043f\u0440\u043e\u0447\u0435\u043c\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443 \u0432\u0441\u0435\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0442\u0430\u043c \u0435\u0449\u0435 \u0434\u043b\u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u0442\u0430\u043c&#8230;<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u044f \u043c\u043e\u0433\u0443 \u043e\u0448\u0438\u0431\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u043b\u0438\u0447\u043d\u043e \u044f \u0443\u0432\u0435\u0440\u0435\u043d \u0434\u043b\u044f \u0441\u0435\u0431\u044f, \u0447\u0442\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f SQL \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 git \u0438\u043b\u0438 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 init \u0444\u0430\u0439\u043b, \u043a\u0430\u043a \u044d\u0442\u043e \u0435\u0441\u0442\u044c \u0432 Yii2.<\/p>\n<p><strong>\u0418\u0434\u0435\u044f<\/strong><\/p>\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f SQL \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0432\u043e\u0435\u043c 2 SQL \u0444\u0430\u0439\u043b\u0430. \u0414\u0430, \u0432\u043e\u0442 \u0442\u0443\u0442 \u0441\u0435\u0439\u0447\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0448\u043a\u0432\u0430\u043b \u043a\u0440\u0438\u0442\u0438\u043a\u0438 \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u0430 \u0438 \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u043d\u043e \u0441\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0447\u0442\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043c\u044b \u043e\u0442 SQLBuilder \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043d\u0430 \u0447\u0438\u0441\u0442\u044b\u0439 SQL, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 IDE \u043c\u043e\u0436\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c DDL \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u0432\u043e\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u043d\u0430\u0434\u043e \u0432\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0442\u043e-\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u0438\u043b\u0434\u0435\u0440\u043e\u043c, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SQL \u0447\u0438\u0441\u0442\u044b\u0439 \u0432 \u0442\u043e\u043c \u0436\u0435 \u0431\u0438\u043b\u0434\u0435\u0440\u0435, \u0430 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u044d\u0442\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0432\u043f\u0435\u0440\u0435\u043c\u0435\u0448\u043a\u0443&#8230; \u041a\u043e\u0440\u043e\u0447\u0435, \u0442\u0443\u0442 \u044f \u043f\u043e\u043d\u044f\u043b \u0438 \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0432 \u043c\u043e\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u0446\u0435\u043b\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0432\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c, \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e SQL \u043a\u043e\u0434.<\/p>\n<p>\u0421\u0443\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430: \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f, \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0442\u0443\u0434\u0430 \u043a\u043e\u0434 UP \u0438 DOWN, \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u0438\u043b\u0438 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435. \u0412\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430.<\/p>\n<p><strong>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430<\/strong><\/p>\n<p>\u0412 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441&nbsp;<code>SqlMigration<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u044e\u0431\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0434\u043b\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u0434.<\/p>\n<p>\u041a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0431\u044b\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043a\u043b\u0430\u0441\u0441&nbsp;<code>ConsoleSqlMigration<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442&nbsp;<code>SqlMigration<\/code>&nbsp;\u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b. \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442&nbsp;<code>parent::<\/code>&nbsp;\u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u0432\u044b\u0432\u043e\u0434\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c (\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b).<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441&nbsp;<code>DatabaseInterface<\/code>&nbsp;\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a. \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p><strong>schema<\/strong>&nbsp;&#8212; \u0441\u0445\u0435\u043c\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439<\/p>\n<\/li>\n<li>\n<p><strong>table<\/strong>&nbsp;&#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439<\/p>\n<\/li>\n<li>\n<p><strong>path<\/strong>&nbsp;&#8212; \u043f\u0443\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u043b\u044f \u043f\u0430\u043f\u043a\u0438 \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 (\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435) \u0441\u0445\u0435\u043c\u044b, \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u0430\u043f\u043a\u0438 \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 (\u043f\u0440\u0430\u0432). \u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u043d\u0435\u0439.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <code>SqlMigration<\/code> \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u043b\u0430\u0441\u0441 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432, \u043d\u043e \u043c\u0430\u043b\u043e \u043b\u0438 \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443. \u0412 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432:<\/p>\n<ol>\n<li>\n<p><code>public function up(int $count = 0): array;<\/code><\/p>\n<\/li>\n<li>\n<p><code>public function down(int $count = 0): array;<\/code><\/p>\n<\/li>\n<li>\n<p><code>public function history(int $limit = 0): array;<\/code><\/p>\n<\/li>\n<li>\n<p><code>public function create(string $name): bool;<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0430\u043c\u0438 \u0437\u0430 \u0441\u0435\u0431\u044f \u0433\u043e\u0432\u043e\u0440\u044f\u0442. \u041d\u043e \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0443\u043a\u0430\u0436\u0443 \u0442\u0443\u0442 \u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438\u0437 PHPDoc:<\/p>\n<pre><code class=\"php\">\/** \t * \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \t * \t * @param int $count \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f (0 - \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435\u0445) \t * \t * @return array \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439. \u0421\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434: \t * 1. \u0421\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \t * 2. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \t * [ \t *  'success' =&gt; [...], \t *  'error' =&gt; [...] \t * ] \t * \u041a\u043b\u044e\u0447 error \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. \t * \t * @throws SqlMigrationException \t *\/ \tpublic function up(int $count = 0): array; \t \t\/** \t * \u041e\u0442\u043c\u0435\u043d\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \t * \t * @param int $count \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f (0 - \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435\u0445) \t * \t * @return array \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0442\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439. \u0421\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434: \t * 1. \u0421\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \t * 2. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \t * [ \t *  'success' =&gt; [...], \t *  'error' =&gt; [...] \t * ] \t * \u041a\u043b\u044e\u0447 error \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. \t * \t * @throws SqlMigrationException \t *\/ \tpublic function down(int $count = 0): array; \t \t\/** \t * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \t * \t * @param int $limit \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0441\u043f\u0438\u0441\u043a\u0430 (null - \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a) \t * \t * @return array \t *\/ \tpublic function history(int $limit = 0): array; \t \t\/** \t * \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \t * \t * @param string $name \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \t * \t * @return bool \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0435\u0441\u043b\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0430. \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \t * \t * @throws RuntimeException|SqlMigrationException \t *\/ \tpublic function create(string $name): bool;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <code>SqlMigration<\/code>. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u042d\u0442\u043e \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"php\">\/**  * \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438  *\/ public const UP = 'up'; public const DOWN = 'down';<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0443\u0436\u0435\u043d \u043c\u0430\u0441\u0441\u0438\u0432 \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0439 <a href=\"https:\/\/github.com\/mepihindeveloper\/php-database\/blob\/stable\/src\/interfaces\/DatabaseInterface.php\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/a> <code>DatabaseInterface<\/code>. \u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 (DI) \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a:<\/p>\n<pre><code class=\"php\">\/**  * SqlMigration constructor.  *  * @param DatabaseInterface $database \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445  * @param array $settings \u041c\u0430\u0441\u0441\u0438\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a  *  * @throws SqlMigrationException  *\/ public function __construct(DatabaseInterface $database, array $settings) { \t$this-&gt;database = $database; \t$this-&gt;settings = $settings; \t \tforeach (['schema', 'table', 'path'] as $settingsKey) { \t\tif (!array_key_exists($settingsKey, $settings)) { \t\t\tthrow new SqlMigrationException(\"\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 {$settingsKey} \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a.\"); \t\t} \t} }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u044b\u0435 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442. \u041c\u0435\u0442\u043e\u0434 \u0432\u0435\u0440\u043d\u0443\u0442 <code>bool<\/code> \u0435\u0441\u043b\u0438 \u0441\u0445\u0435\u043c\u0430 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0438 \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"php\">\/**  * \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0445\u0435\u043c\u0443 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f  *  * @return bool \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0435\u0441\u043b\u0438 \u0441\u0445\u0435\u043c\u0430 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442  * \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435  *  * @throws SqlMigrationException  *\/ public function initSchemaAndTable(): bool { \t$schemaSql = &lt;&lt;&lt;SQL \t\tCREATE SCHEMA IF NOT EXISTS {$this-&gt;settings['schema']}; \tSQL; \t \tif (!$this-&gt;database-&gt;execute($schemaSql)) { \t\tthrow new SqlMigrationException('\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438'); \t} \t \t$tableSql = &lt;&lt;&lt;SQL \t\tCREATE TABLE IF NOT EXISTS {$this-&gt;settings['schema']}.{$this-&gt;settings['table']} ( \t\t\t\"name\" varchar(180) COLLATE \"default\" NOT NULL, \t\t\tapply_time int4, \t\t\tCONSTRAINT {$this-&gt;settings['table']}_pk PRIMARY KEY (\"name\") \t\t) WITH (OIDS=FALSE) \tSQL; \t \tif (!$this-&gt;database-&gt;execute($tableSql)) { \t\tthrow new SqlMigrationException('\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438'); \t} \t \treturn true; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438\u043c\u0435\u043d\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 (\u043f\u0430\u043f\u043a\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438):<\/p>\n<pre><code class=\"php\">\/**  * \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0438\u043c\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c  *  * @param string $name \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438  *  * @throws SqlMigrationException  *\/ protected function validateName(string $name): void { \tif (!preg_match('\/^[\\w]+$\/', $name)) { \t\tthrow new SqlMigrationException('\u0418\u043c\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u043a\u0432\u044b, \u0446\u0438\u0444\u0440\u044b \u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u044f.'); \t} }  \/**  * \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0438\u043c\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443: m{\u0434\u0430\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Ymd_His}_name  *  * @param string $name \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438  *  * @return string  *\/ protected function generateName(string $name): string { \treturn 'm' . gmdate('Ymd_His') . \"_{$name}\"; }<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0430\u043f\u043a\u0438 \u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043d\u0435\u0439. \u041f\u0430\u043f\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0438\u043c\u0435\u043d\u0438: m_\u0434\u0430\u0442\u0430_\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435_\u0438\u043c\u044f &#8212; \u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u0443\u043a\u0432\u044b, \u0446\u0438\u0444\u0440\u044b \u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"php\">\/**  * @inheritDoc  *  * @throws RuntimeException|SqlMigrationException  *\/ public function create(string $name): bool { \t$this-&gt;validateName($name); \t \t$migrationMame = $this-&gt;generateName($name); \t$path = \"{$this-&gt;settings['path']}\/{$migrationMame}\"; \t \tif (!mkdir($path, 0775, true) &amp;&amp; !is_dir($path)) { \t\tthrow new RuntimeException(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. \u0414\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f {$path}\u043d\u0435 \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430\"); \t} \t \tif (file_put_contents($path . '\/up.sql', '') === false) { \t\tthrow new RuntimeException(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 {$path}\/up.sql\"); \t} \t \tif (!file_put_contents($path . '\/down.sql', '') === false) { \t\tthrow new RuntimeException(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 {$path}\/down.sql\"); \t} \t \treturn true; }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439, \u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439:<\/p>\n<pre><code class=\"php\">\/**  * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439  *  * @param int $limit \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0441\u043f\u0438\u0441\u043a\u0430 (null - \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a)  *  * @return array  *\/ protected function<\/code><\/pre>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-322610","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322610","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322610"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322610\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}