{"id":357757,"date":"2024-05-20T23:57:30","date_gmt":"2024-05-20T23:57:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=357757"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-20T23:57:30","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=357757","title":{"rendered":"<span>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 (Job) \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c Laravel \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043c\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0438\u043b\u0438 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430 PostgreSQL<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c?<\/h2>\n<p>\u0415\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>A<\/strong> , \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u0442\u0430\u043c, \u0438 \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u042d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 API \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440. \u0415\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>B<\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <strong>\u0410<\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0440\u043e\u0438\u0442 \u043e\u0442\u0447\u0451\u0442\u044b \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <strong>\u0410<\/strong>. \u041a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e <strong>B<\/strong> \u0438 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u043c \u0443 \u043c\u0435\u043d\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u0435\u0441\u0442\u044c.<\/p>\n<p>\u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>B<\/strong> \u043e\u0431\u0440\u0430\u0441\u043b\u043e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u043e\u043c. \u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u0441\u0435\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c, \u0438 \u0442\u0443\u0442 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0430 \u0445\u043e\u0442\u0435\u043b\u043a\u0430: \u043a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 <strong>\u0410<\/strong> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <strong>X<\/strong>, \u043e\u043f\u043e\u0432\u0435\u0449\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <strong>B<\/strong> \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430.<\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e\u0439, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>A<\/strong> \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u043b\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>B<\/strong> \u043e \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f <strong>X<\/strong>.<\/p>\n<p>\u041d\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f <strong>X<\/strong>, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>A<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u043c\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 <strong>Y<\/strong>. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0432, \u044f \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u0438\u0435 (Job) \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 <strong>B<\/strong>, \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0432 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 jobs. \u0410 \u0443\u0436 \u044d\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430.<\/p>\n<h2>\u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0443\u0441\u043f\u0435\u0445\u0430?<\/h2>\n<p>\u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d, \u043a\u0430\u043a <strong>database<\/strong>. \u0414\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0438 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b \u0432\u043e\u0440\u043a\u0435\u0440\u044b.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041b\u0443\u0447\u0448\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438 \u043f\u043e\u0449\u0443\u043f\u0430\u0442\u044c, \u0447\u0435\u043c \u0441\u0442\u043e \u0440\u0430\u0437 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0435\u043e\u0440\u0438\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0432 \u0432\u0438\u0434\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u044d\u0442\u043e \u0438\u0437\u043b\u0438\u0448\u043d\u0438\u043c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u043a <a href=\"#insert_record\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0443<\/a>. \u0412\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043d\u0430\u0447\u0430\u043b\u0443 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u043e\u0437\u0434\u043d\u043e.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u044f \u043d\u0435 \u043d\u0430\u0448\u0451\u043b, \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u00ab\u0432 \u043b\u043e\u0431\u00bb \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>\u041d\u043e \u043e\u0431\u0449\u0443\u044e \u0438\u0434\u0435\u044e \u044f \u043e\u043f\u0438\u0448\u0443.<\/p>\n<p>\u041d\u0430\u0448\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0438\u0441\u044c\u043c\u043e \u0438 \u044d\u0442\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u043c\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043e\u0439.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<pre><code class=\"bash\">composer create-project laravel\/laravel pgsql_job cd pgsql_job sudo chown -R $USER:www-data storage sudo chown -R $USER:www-data bootstrap\/cache chmod -R 775 storage chmod -R 775 bootstrap\/cache<\/code><\/pre>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0431\u0430\u0437\u044b \u043d\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c<\/p>\n<details class=\"spoiler\">\n<summary>docker-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">docker run -d -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test \\ -p 5432:5432 --name pgsql postgres<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0431\u0430\u0437\u0435. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 .env<\/p>\n<pre><code class=\"php\">DB_CONNECTION=pgsql DB_HOST=127.0.0.1 DB_PORT=5432 DB_DATABASE=test DB_USERNAME=test DB_PASSWORD=test <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0443\u043a\u0430\u0436\u0438\u0442\u0435 <strong>database <\/strong>(QUEUE_CONNECTION=database). <\/p>\n<p>\u041e\u043f\u044b\u0442\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u043f\u0438\u0441\u0435\u043c. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u043f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 MAIL_MAILER=log. \u041f\u0443\u0441\u0442\u044c \u043f\u0438\u0441\u044c\u043c\u0430 \u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043b\u043e\u0433\u0438.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f<\/h2>\n<pre><code class=\"bash\">make:php artisan make:notification TestNotify<\/code><\/pre>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 <abbr class=\"habraabbr\" title=\"\" data-title=\"&lt;p>&lt;\/p>&#187; data-abbr=&#187;app\/Notifications\/TestNotify.php&#187;>app\/Notifications\/TestNotify.php<\/abbr> \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440<\/p>\n<pre><code class=\"php\">    public function __construct(public $subject, public $id)     {         \/\/     }<\/code><\/pre>\n<p>\u0438 \u043c\u0435\u0442\u043e\u0434 <abbr class=\"habraabbr\" title=\"\" data-title=\"&lt;p>&lt;\/p>&#187; data-abbr=&#187;toMail()&#187;>toMail()<\/abbr><\/p>\n<pre><code class=\"php\">    public function toMail(object $notifiable): MailMessage     {         return (new MailMessage)             ->subject($this->subject)             ->line('ID: ' . $this->id);     }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace App\\Notifications;  use Illuminate\\Bus\\Queueable; use Illuminate\\Notifications\\Messages\\MailMessage; use Illuminate\\Notifications\\Notification;  class TestNotify extends Notification {     use Queueable;      public function __construct(public $subject, public $id)     {         \/\/     }      public function via(object $notifiable): array     {         return ['mail'];     }      public function toMail(object $notifiable): MailMessage     {         return (new MailMessage)             ->subject($this->subject)             ->line('ID: ' . $this->id);     }      public function toArray(object $notifiable): array     {         return [             \/\/         ];     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u043d\u0430\u0448\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 tinker<\/p>\n<pre><code class=\"bash\">php artisan tinker<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0438\u043c \u043a\u043e\u0434<\/p>\n<pre><code class=\"php\"> use App\\Notifications\\TestNotify;  Notification::route('mail', 'test@mail.ru')->notify(new TestNotify('Test Subject', 123456));<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043b\u043e\u0433<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b52\/41c\/b9e\/b5241cb9ed1cb4a19be2b08c471dee2a.png\" width=\"684\" height=\"405\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b52\/41c\/b9e\/b5241cb9ed1cb4a19be2b08c471dee2a.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0412\u0441\u0451 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435. \u0418 \u0442\u0435\u043c\u0430 \u043f\u0438\u0441\u044c\u043c\u0430, \u0438 ID \u0438 \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0439 \u0430\u0434\u0440\u0435\u0441. \u041b\u043e\u0433 \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u0444\u0430\u043a\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u0438\u0441\u044c\u043c\u0430.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f<\/h2>\n<pre><code class=\"bash\">php artisan make:job TestJob<\/code><\/pre>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 <abbr class=\"habraabbr\" title=\"\" data-title=\"&lt;p>&lt;\/p>&#187; data-abbr=&#187;app\/Jobs\/TestJob.php&#187;>app\/Jobs\/TestJob.php<\/abbr> \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440<\/p>\n<pre><code class=\"php\">    public function __construct(public $email, public $subject, public $id)     {         \/\/     }<\/code><\/pre>\n<p>\u0438 \u043c\u0435\u0442\u043e\u0434 <abbr class=\"habraabbr\" title=\"\" data-title=\"&lt;p>&lt;\/p>&#187; data-abbr=&#187;handle()&#187;>handle()<\/abbr><\/p>\n<pre><code class=\"php\">    public function handle(): void     {         Notification::route('mail', $this->email)->notify(new TestNotify($this->subject, $this->id));     }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace App\\Jobs;  use App\\Notifications\\TestNotify; use Illuminate\\Bus\\Queueable; use Illuminate\\Contracts\\Queue\\ShouldQueue; use Illuminate\\Foundation\\Bus\\Dispatchable; use Illuminate\\Queue\\InteractsWithQueue; use Illuminate\\Queue\\SerializesModels; use Illuminate\\Support\\Facades\\Notification;  class TestJob implements ShouldQueue {     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;      public function __construct(public $email, public $subject, public $id)     {         \/\/     }      public function handle(): void     {         Notification::route('mail', $this->email)->notify(new TestNotify($this->subject, $this->id));     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 <strong>sync <\/strong>(QUEUE_CONNECTION=sync) \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432 tinker. \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0451 \u0438\u0437 \u043d\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0448\u043b\u0438 \u2014 \u0432\u044b\u0439\u0434\u0438\u0442\u0435. \u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 tinker \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u043d\u0430\u0448\u0435\u043c \u043d\u043e\u0432\u043e\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0438. \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 tinker \u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0438\u043c<\/p>\n<pre><code class=\"php\">use App\\Jobs\\TestJob; \\Bus::dispatch(new TestJob('tset@liam.ur', 'Subject Test', 654321));<\/code><\/pre>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0435? \u041e\u0442\u0432\u0435\u0442 <a href=\"https:\/\/github.com\/laravel\/tinker\/commit\/1baadfe1721f85cd4e776aa323128dcd329f170d#diff-04c6e90faac2675aa89e2176d2eec7d8\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043b\u043e\u0433<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1fe\/fd5\/3ac\/1fefd53ac82df2365c6da95424a1fa7d.png\" width=\"723\" height=\"395\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1fe\/fd5\/3ac\/1fefd53ac82df2365c6da95424a1fa7d.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u043f\u044f\u0442\u044c \u0432\u0441\u0451 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435. \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u043b\u043e\u0433, \u043c\u0435\u043d\u044f\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 <strong>database<\/strong>.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442. \u041d\u0430\u0441\u0442\u0430\u043b\u0430 \u043f\u043e\u0440\u0430 \u00ab\u0437\u0430\u0441\u0443\u043d\u0443\u0442\u044c\u00bb \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u0445\u0440\u0430\u043d\u0438\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0439\u043c\u0451\u043c, \u043a\u0430\u043a \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<h2>\u0414\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b jobs<\/h2>\n<p>\u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u043b\u0438? \u0412\u044b\u0439\u0434\u0438\u0442\u0435 \u0438 \u0432\u043e\u0439\u0434\u0438\u0442\u0435 \u0432 \u0442\u0438\u043d\u043a\u0435\u0440. \u0418\u043d\u0430\u0447\u0435 \u0442\u0438\u043d\u043a\u0435\u0440 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0451 \u0440\u0430\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043d\u043a\u0435\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c. \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <strong>jobs <\/strong>\u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cc9\/a10\/d51\/cc9a10d519ac615b52e3de8262146c22.png\" alt=\"\u0417\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b jobs\" title=\"\u0417\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b jobs\" width=\"1176\" height=\"83\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cc9\/a10\/d51\/cc9a10d519ac615b52e3de8262146c22.png\"\/><\/p>\n<div><figcaption>\u0417\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b jobs<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u043b\u044f <strong>available_at<\/strong> \u0438 <strong>created_at<\/strong> \u0440\u0430\u0432\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/www.php.net\/manual\/ru\/function.time.php\" rel=\"noopener noreferrer nofollow\">time()<\/a> \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u042d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u043a\u0443\u043d\u0434, \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0445 \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u044d\u043f\u043e\u0445\u0438 Unix (1 \u044f\u043d\u0432\u0430\u0440\u044f 1970 00:00:00 GMT) \u0434\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>\u041f\u043e\u043b\u0435 <strong>payload<\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 json, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f.<\/p>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u0442\u0438\u043d\u043a\u0435\u0440, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c<\/p>\n<pre><code class=\"php\">json_decode(\\DB::table('jobs')->first()->payload);<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"php\">> json_decode(\\DB::table('jobs')->first()->payload); = {#6275     +\"uuid\": \"0c2c7167-804a-4bed-9991-8827571f6be8\",     +\"displayName\": \"App\\Jobs\\TestJob\",     +\"job\": \"Illuminate\\Queue\\CallQueuedHandler@call\",     +\"maxTries\": null,     +\"maxExceptions\": null,     +\"failOnTimeout\": false,     +\"backoff\": null,     +\"timeout\": null,     +\"retryUntil\": null,     +\"data\": {#6298       +\"commandName\": \"App\\Jobs\\TestJob\",       +\"command\": \"O:16:\"App\\Jobs\\TestJob\":3:{s:5:\"email\";s:12:\"tset@liam.ur\";s:7:\"subject\";s:12:\"Subject Test\";s:2:\"id\";i:654321;}\",     },   } <\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 json \u0432 PostgreSQL \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 data->command, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <abbr class=\"habraabbr\" title=\"\" data-title=\"&lt;p>&lt;\/p>&#187; data-abbr=&#187;App\\Jobs\\TestJob&#187;>App\\Jobs\\TestJob<\/abbr><\/p>\n<p>\u041f\u043e\u0434\u0430\u0451\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 tinker<\/p>\n<pre><code class=\"php\">unserialize(json_decode(\\DB::table('jobs')->first()->payload)->data->command);<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c<\/p>\n<pre><code class=\"php\">> unserialize(json_decode(\\DB::table('jobs')->first()->payload)->data->command); = App\\Jobs\\TestJob {#6318       +email: \"tset@liam.ur\",     +subject: \"Subject Test\",     +id: 654321,     +job: null,     +connection: null,     +queue: null,     +chainConnection: null,     +chainQueue: null,     +chainCatchCallbacks: null,     +delay: null,     +afterCommit: null,     +middleware: [],     +chained: [],   } <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e PostgreSQL \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b PHP \u0438 \u043e\u0431 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0438\u043d\u044f\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u044d\u0442\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u043a\u0430\u043a \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0439. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 PostgreSQL<\/p>\n<p><a class=\"anchor\" name=\"insert_record\" id=\"insert_record\"><\/a><\/p>\n<h2>\u0412\u0441\u0442\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 jobs \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 PostgreSQL<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 jobs \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c uuid<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u043a\u0443\u043d\u0434, \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0445 \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u044d\u043f\u043e\u0445\u0438 Unix (1 \u044f\u043d\u0432\u0430\u0440\u044f 1970 00:00:00 GMT) \u0434\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/p>\n<\/li>\n<li>\n<p>\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c json, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0435<\/p>\n<\/li>\n<\/ul>\n<h3>\u0423\u0447\u0438\u043c PostgreSQL \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c uuid<\/h3>\n<h4>\u0414\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0438 13 \u0438 \u0432\u044b\u0448\u0435<\/h4>\n<p>PostgreSQL \u0432\u0435\u0440\u0441\u0438\u0438 13 \u0438 \u0432\u044b\u0448\u0435 \u0443\u043c\u0435\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c uuid v 4 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438.<\/p>\n<pre><code class=\"sql\">SELECT gen_random_uuid();<\/code><\/pre>\n<pre><code>           gen_random_uuid             --------------------------------------  5a103975-1419-4a4b-9afb-a4743f3d54a3<\/code><\/pre>\n<h4>\u0414\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0438\u0436\u0435 13<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c uuid \u0432 PostgreSQL \u043d\u0438\u0436\u0435 13-\u0439 \u0432\u0435\u0440\u0441\u0438\u0438, \u043d\u0443\u0436\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435\u0441\u044f \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/15\/uuid-ossp\" rel=\"noopener noreferrer nofollow\">uuid-ossp<\/a>. \u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043e\u0442\u043a\u043b\u044e\u0447\u0451\u043d \u0438 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c. \u042f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043b\u0438 \u043d\u0443\u0436\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u043e\u043a\u0435\u0440-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435.<\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0441\u044c \u043a \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443<\/p>\n<pre><code class=\"bash\">docker container exec -it pgsql bash<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0441\u044c \u043a \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 PostgreSQL \u2014 psql<\/p>\n<pre><code class=\"bash\"># psql -U test<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u044e, \u043a\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b<\/p>\n<pre><code class=\"sql\">test=# \\df                        List of functions  Schema | Name | Result data type | Argument data types | Type --------+------+------------------+---------------------+------ (0 rows)<\/code><\/pre>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 uuid \u043d\u0435\u0442. \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c.<\/p>\n<pre><code class=\"sql\">test=# CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\"; CREATE EXTENSION test-# \\df                                  List of functions  Schema |        Name        | Result data type |    Argument data types    | Type --------+--------------------+------------------+---------------------------+------  public | uuid_generate_v1   | uuid             |                           | func  public | uuid_generate_v1mc | uuid             |                           | func  public | uuid_generate_v3   | uuid             | namespace uuid, name text | func  public | uuid_generate_v4   | uuid             |                           | func  public | uuid_generate_v5   | uuid             | namespace uuid, name text | func  public | uuid_nil           | uuid             |                           | func  public | uuid_ns_dns        | uuid             |                           | func  public | uuid_ns_oid        | uuid             |                           | func  public | uuid_ns_url        | uuid             |                           | func  public | uuid_ns_x500       | uuid             |                           | func (10 rows)<\/code><\/pre>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f uuid_generate_v4. \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u044e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. <\/p>\n<pre><code class=\"sql\">test=# select uuid_generate_v4();            uuid_generate_v4 --------------------------------------  8a7a8be0-e4cd-4c0a-8275-dcf2ed58c5a9 (1 row)<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044c \u043a <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/15\/uuid-ossp#id-1.11.7.58.6\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e PostgreSQL<\/a>.<\/p>\n<blockquote>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0437\u0430\u0432\u0438\u0441\u0435\u043b \u043e\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 OSSP UUID, \u0447\u0442\u043e \u043e\u0442\u0440\u0430\u0437\u0438\u043b\u043e\u0441\u044c \u0432 \u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438. \u0425\u043e\u0442\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 OSSP UUID \u0432\u0441\u0451 \u0435\u0449\u0451 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443\u00a0<a href=\"http:\/\/www.ossp.org\/pkg\/lib\/uuid\/\" rel=\"noopener noreferrer nofollow\">http:\/\/www.ossp.org\/pkg\/lib\/uuid\/<\/a>, \u043e\u043d\u0430 \u043f\u043b\u043e\u0445\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u0435\u0451 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u0441\u0451 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>uuid-ossp<\/code>\u00a0\u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 OSSP. \u0412\u043e FreeBSD \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u041e\u0421 \u043d\u0430 \u0431\u0430\u0437\u0435 BSD \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f UUID \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443\u00a0<code>libc<\/code>. \u0412 Linux, macOS \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439\u00a0<code>libuuid<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0448\u043b\u0430 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u00a0<code>e2fsprogs<\/code>\u00a0(\u0445\u043e\u0442\u044f \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0430\u0445 Linux \u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043f\u0430\u043a\u0435\u0442\u0430\u00a0<code>util-linux-ng<\/code>). \u0412\u044b\u0437\u044b\u0432\u0430\u044f\u00a0<code>configure<\/code>, \u043f\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 \u043a\u043b\u044e\u0447\u00a0<code>--with-uuid=bsd<\/code>, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 BSD, \u043b\u0438\u0431\u043e\u00a0<code>--with-uuid=e2fs<\/code>, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u00a0<code>libuuid<\/code>\u00a0\u0438\u0437\u00a0<code>e2fsprogs<\/code>, \u043b\u0438\u0431\u043e \u043a\u043b\u044e\u0447\u00a0<code>--with-uuid=ossp<\/code>, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 OSSP UUID. \u0412 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443\u00a0<code>configure<\/code>\u00a0\u043d\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.  <\/p>\n<\/blockquote>\n<h3>\u0423\u0447\u0438\u043c PostgreSQL \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0435\u043a\u0443\u043d\u0434\u044b<\/h3>\n<p>\u0412 PostgreSQL \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 time() \u0432 PHP. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u043a\u0443\u043d\u0434 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/p>\n<pre><code class=\"sql\">test=# select extract(epoch from current_timestamp)::integer;   extract ------------  1697631498 (1 row)<\/code><\/pre>\n<h3>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c json<\/h3>\n<p>\u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u0432\u0437\u044f\u0442\u044c \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f. \u0411\u0435\u0440\u0451\u043c \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u0434\u0430\u043d\u043d\u043e\u0439 \u0432 \u0442\u0438\u043d\u043a\u0435\u0440 \u043a\u043e\u043c\u0430\u043d\u0434\u044b: <em>json_decode(\\DB::table(&#8216;jobs&#8217;)->first()->payload)<\/em> \u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c json.<\/p>\n<pre><code class=\"sql\">select json_build_object(                'uuid', uuid_generate_v4(),                'displayName', 'App\\Jobs\\TestJob',                'job', 'Illuminate\\Queue\\CallQueuedHandler@call',                'maxTries', null,                'maxExceptions', null,                'failOnTimeout', false,                'backoff', null,                'timeout', null,                'retryUntil', null,                'data', (json_build_object('commandName', 'App\\Jobs\\TestJob',                                           'command', 'O:16:\"App\\Jobs\\TestJob\":3:{s:5:\"email\";s:12:\"tset@liam.ur\";s:7:\"subject\";s:12:\"Subject Test\";s:2:\"id\";i:654321;}'))        ); <\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e uuid \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 payload \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u043d\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0435. <\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043f\u043e\u043b\u0435 command. \u042f \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u0442\u0440\u043e\u043a\u043e\u0439. \u0412 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u041c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0432 \u0437\u0430\u0434\u0430\u0447\u0443 \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: \u0434\u0432\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u2014 email \u0438 subject \u0438 \u043e\u0434\u0438\u043d \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439. \u041a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0435\u043b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430. \u041d\u0430\u0439\u0434\u0451\u043c \u044d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a8a\/46a\/33c\/a8a46a33cecfeba3f7a0f0394a2b4e70.png\" width=\"899\" height=\"198\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a8a\/46a\/33c\/a8a46a33cecfeba3f7a0f0394a2b4e70.png\"\/><\/figure>\n<p>email: s:12:&#187;tset@liam.ur&#187;. s \u2014 \u0441\u0442\u0440\u043e\u043a\u0430, 12 \u2014 \u0434\u043b\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438, &#171;tset@liam.ur&#187; \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0434\u0432\u043e\u0439\u043d\u044b\u043c\u0438 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u043c\u0438.<\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f subject. <\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 id: i:654321 i \u2014 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, 654321 \u2014 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b: \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 PostgreSQL \u0441 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u0438\u043d\u044b \u0441\u0442\u0440\u043e\u043a, \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 utf-8,  \u0440\u043e\u0432\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u0431\u0435\u0434\u0430, \u043a\u0430\u043a \u0438 \u0432 PHP. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u0438\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 octet_length();<\/p>\n<p>\u0427\u0430\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/p>\n<pre><code class=\"pgsql\">_command = 'O:16:\"App\\Jobs\\TestJob\":3:{s:5:\"email\";s:' ||                octet_length(_email) || ':\"' ||                _email ||'\";s:7:\"subject\";s:'||                octet_length(_subject) ||':\"' ||                _subject || '\";s:2:\"id\";i:' || _id::varchar || ';}';<\/code><\/pre>\n<h2>\u0424\u0443\u043d\u043a\u0446\u0438\u044f PostgreSQL<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e<\/p>\n<pre><code class=\"bash\">php artisan make:migration create_set_job_function<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  use Illuminate\\Database\\Migrations\\Migration; use Illuminate\\Database\\Schema\\Blueprint; use Illuminate\\Support\\Facades\\Schema;  return new class extends Migration {     public function up(): void     {         $sql = &lt;&lt;&lt;HERE create function set_job(_email character varying, _subject character varying, _id integer) returns void     language plpgsql as $$ declare     _time int;     _payload json;     _command varchar;  begin     _time := extract(epoch from current_timestamp)::integer;     _command = 'O:16:\"App\\Jobs\\TestJob\":3:{s:5:\"email\";s:' ||                octet_length(_email) || ':\"' ||                _email ||'\";s:7:\"subject\";s:'||                octet_length(_subject) ||':\"' ||                _subject || '\";s:2:\"id\";i:' || _id::varchar || ';}';     _payload = json_build_object(             'uuid', uuid_generate_v4(),             'displayName', 'App\\Jobs\\TestJob',             'job', 'Illuminate\\Queue\\CallQueuedHandler@call',             'maxTries', null,             'maxExceptions', null,             'failOnTimeout', false,             'backoff', null,             'timeout', null,             'retryUntil', null,             'data', (json_build_object('commandName', 'App\\Jobs\\TestJob',                                        'command', _command)));     insert into jobs(queue, payload, attempts, reserved_at, available_at, created_at)         values ('default', _payload, 0, null, _time, _time); end; $$;  alter function set_job(varchar, varchar, integer) owner to test; HERE;         DB::unprepared($sql);     }      public function down(): void     {         DB::unprepared('drop function if exists set_job');     } }; <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e<\/p>\n<pre><code class=\"bash\">php artisan migrate <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0438 \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/p>\n<pre><code class=\"sql\">test=# select set_job('e@mail.ru', '\u041a\u0438\u0440\u0438\u043b\u0438\u0446\u0430 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435', 9876);  set_job ---------  (1 row)<\/code><\/pre>\n<p>\u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u043e\u0440\u043a\u0435\u0440<\/p>\n<pre><code class=\"bash\">php artisan queue:work --once<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0418 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043b\u043e\u0433<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/399\/272\/33c\/39927233cecc6d643176cb6c43890593.png\" width=\"770\" height=\"462\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/399\/272\/33c\/39927233cecc6d643176cb6c43890593.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u0451 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435.<\/p>\n<h2>\u042d\u043f\u0438\u043b\u043e\u0433<\/h2>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u043d\u0435\u0445\u0438\u0442\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c Laravel \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445: \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0438 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430\u0445. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/768136\/\"> https:\/\/habr.com\/ru\/articles\/768136\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c?<\/h2>\n<p>\u0415\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>A<\/strong> , \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u0442\u0430\u043c, \u0438 \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u042d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 API \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440. \u0415\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>B<\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <strong>\u0410<\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0440\u043e\u0438\u0442 \u043e\u0442\u0447\u0451\u0442\u044b \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <strong>\u0410<\/strong>. \u041a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e <strong>B<\/strong> \u0438 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u043c \u0443 \u043c\u0435\u043d\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u0435\u0441\u0442\u044c.<\/p>\n<p>\u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>B<\/strong> \u043e\u0431\u0440\u0430\u0441\u043b\u043e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u043e\u043c. \u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u0441\u0435\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c, \u0438 \u0442\u0443\u0442 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0430 \u0445\u043e\u0442\u0435\u043b\u043a\u0430: \u043a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 <strong>\u0410<\/strong> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <strong>X<\/strong>, \u043e\u043f\u043e\u0432\u0435\u0449\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <strong>B<\/strong> \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430.<\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e\u0439, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>A<\/strong> \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u043b\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>B<\/strong> \u043e \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f <strong>X<\/strong>.<\/p>\n<p>\u041d\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f <strong>X<\/strong>, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <strong>A<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u043c\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 <strong>Y<\/strong>. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0432, \u044f \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u0438\u0435 (Job) \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 <strong>B<\/strong>, \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0432 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 jobs. \u0410 \u0443\u0436 \u044d\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430.<\/p>\n<h2>\u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0443\u0441\u043f\u0435\u0445\u0430?<\/h2>\n<p>\u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d, \u043a\u0430\u043a <strong>database<\/strong>. \u0414\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0438 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b \u0432\u043e\u0440\u043a\u0435\u0440\u044b.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041b\u0443\u0447\u0448\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438 \u043f\u043e\u0449\u0443\u043f\u0430\u0442\u044c, \u0447\u0435\u043c \u0441\u0442\u043e \u0440\u0430\u0437 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0435\u043e\u0440\u0438\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0432 \u0432\u0438\u0434\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u044d\u0442\u043e \u0438\u0437\u043b\u0438\u0448\u043d\u0438\u043c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u043a <a href=\"#insert_record\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0443<\/a>. \u0412\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043d\u0430\u0447\u0430\u043b\u0443 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u043e\u0437\u0434\u043d\u043e.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u044f \u043d\u0435 \u043d\u0430\u0448\u0451\u043b, \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u00ab\u0432 \u043b\u043e\u0431\u00bb \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>\u041d\u043e \u043e\u0431\u0449\u0443\u044e \u0438\u0434\u0435\u044e \u044f \u043e\u043f\u0438\u0448\u0443.<\/p>\n<p>\u041d\u0430\u0448\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0438\u0441\u044c\u043c\u043e \u0438 \u044d\u0442\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u043c\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043e\u0439.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<pre><code class=\"bash\">composer create-project laravel\/laravel pgsql_job cd pgsql_job sudo chown -R $USER:www-data storage sudo chown -R $USER:www-data bootstrap\/cache chmod -R 775 storage chmod -R 775 bootstrap\/cache<\/code><\/pre>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0431\u0430\u0437\u044b \u043d\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c<\/p>\n<details class=\"spoiler\">\n<summary>docker-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">docker run -d -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test \\ -p 5432:5432 --name pgsql postgres<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0431\u0430\u0437\u0435. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 .env<\/p>\n<pre><code class=\"php\">DB_CONNECTION=pgsql DB_HOST=127.0.0.1 DB_PORT=5432 DB_DATABASE=test DB_USERNAME=test DB_PASSWORD=test <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0443\u043a\u0430\u0436\u0438\u0442\u0435 <strong>database <\/strong>(QUEUE_CONNECTION=database). <\/p>\n<p>\u041e\u043f\u044b\u0442\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u043f\u0438\u0441\u0435\u043c. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u043f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 MAIL_MAILER=log. \u041f\u0443\u0441\u0442\u044c \u043f\u0438\u0441\u044c\u043c\u0430 \u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043b\u043e\u0433\u0438.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f<\/h2>\n<pre><code class=\"bash\">make:php artisan make:notification TestNotify<\/code><\/pre>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 <abbr class=\"habraabbr\" title=\"\" data-title=\"&lt;p>&lt;\/p>&#187; data-abbr=&#187;app\/Notifications\/TestNotify.php&#187;>app\/Notifications\/TestNotify.php<\/abbr> \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440<\/p>\n<pre><code class=\"php\">    public function __construct(public $subject, public $id)     {         \/\/     }<\/code><\/pre>\n<p>\u0438 \u043c\u0435\u0442\u043e\u0434 <abbr class=\"habraabbr\" title=\"\" data-title=\"&lt;p>&lt;\/p>&#187; data-abbr=&#187;toMail()&#187;>toMail()<\/abbr><\/p>\n<pre><code class=\"php\">    public function toMail(object $notifiable): MailMessage     {         return (new MailMessage)             ->subject($this->subject)             ->line('ID: ' . $this->id);     }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace App\\Notifications;  use Illuminate\\Bus\\Queueable; use Illuminate\\Notifications\\Messages\\MailMessage; use Illuminate\\Notifications\\Notification;  class TestNotify extends Notification {     use Queueable;      public function __construct(public $subject, public $id)     {         \/\/     }      public function via(object $notifiable): array     {         return ['mail'];     }      public function toMail(object $notifiable): MailMessage     {         return (new MailMessage)             ->subject($this->subject)             ->line('ID: ' . $this->id);     }      public function toArray(object $notifiable): array     {         return [             \/\/         ];     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u043d\u0430\u0448\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 tinker<\/p>\n<pre><code class=\"bash\">php artisan tinker<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0438\u043c \u043a\u043e\u0434<\/p>\n<pre><code class=\"php\"> use App\\Notifications\\TestNotify;  Notification::route('mail', 'test@mail.ru')->notify(new TestNotify('Test Subject', 123456));<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043b\u043e\u0433<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0412\u0441\u0451 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435. \u0418 \u0442\u0435\u043c\u0430 \u043f\u0438\u0441\u044c\u043c\u0430, \u0438 ID \u0438 \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0439 \u0430\u0434\u0440\u0435\u0441. \u041b\u043e\u0433 \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u0444\u0430\u043a\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u0438\u0441\u044c\u043c\u0430.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f<\/h2>\n<pre><code class=\"bash\">php artisan make:job TestJob<\/code><\/pre>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 <abbr class=\"habraabbr\" title=\"\" data-title=\"&lt;p>&lt;\/p>&#187; data-abbr=&#187;app\/Jobs\/TestJob.php&#187;>app\/Jobs\/TestJob.php<\/abbr> \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440<\/p>\n<pre><code class=\"php\">    public function __construct(public $email, public $subject, public $id)     {         \/\/     }<\/code><\/pre>\n<p>\u0438 \u043c\u0435\u0442\u043e\u0434 <abbr class=\"habraabbr\" title=\"\" data-title=\"&lt;p>&lt;\/p>&#187; data-abbr=&#187;handle()&#187;>handle()<\/abbr><\/p>\n<pre><code class=\"php\">    public function handle(): void     {         Notification::route('mail', $this->email)->notify(new TestNotify($this->subject, $this->id));     }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace App\\Jobs;  use App\\Notifications\\TestNotify; use Illuminate\\Bus\\Queueable; use Illuminate\\Contracts\\Queue\\ShouldQueue; use Illuminate\\Foundation\\Bus\\Dispatchable; use Illuminate\\Queue\\InteractsWithQueue; use Illuminate\\Queue\\SerializesModels; use Illuminate\\Support\\Facades\\Notification;  class TestJob implements ShouldQueue {     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;      public function __construct(public $email, public $subject, public $id)     {         \/\/     }      public function handle(): void     {         Notification::route('mail', $this->email)->notify(new TestNotify($this->subject, $this->id));     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 <strong>sync <\/strong>(QUEUE_CONNECTION=sync) \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432 tinker. \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0451 \u0438\u0437 \u043d\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0448\u043b\u0438 \u2014 \u0432\u044b\u0439\u0434\u0438\u0442\u0435. \u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 tinker \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u043d\u0430\u0448\u0435\u043c \u043d\u043e\u0432\u043e\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0438. \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 tinker \u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0438\u043c<\/p>\n<pre><code class=\"php\">use App\\Jobs\\TestJob; \\Bus::dispatch(new TestJob('tset@liam.ur', 'Subject Test', 654321));<\/code><\/pre>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0435? \u041e\u0442\u0432\u0435\u0442 <a href=\"https:\/\/github.com\/laravel\/tinker\/commit\/1baadfe1721f85cd4e776aa323128dcd329f170d#diff-04c6e90faac2675aa89e2176d2eec7d8\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043b\u043e\u0433<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u043f\u044f\u0442\u044c \u0432\u0441\u0451 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435. \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u043b\u043e\u0433, \u043c\u0435\u043d\u044f\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 <strong>database<\/strong>.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442. \u041d\u0430\u0441\u0442\u0430\u043b\u0430 \u043f\u043e\u0440\u0430 \u00ab\u0437\u0430\u0441\u0443\u043d\u0443\u0442\u044c\u00bb \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u0445\u0440\u0430\u043d\u0438\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0439\u043c\u0451\u043c, \u043a\u0430\u043a \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<h2>\u0414\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b jobs<\/h2>\n<p>\u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u043b\u0438? \u0412\u044b\u0439\u0434\u0438\u0442\u0435 \u0438 \u0432\u043e\u0439\u0434\u0438\u0442\u0435 \u0432 \u0442\u0438\u043d\u043a\u0435\u0440. \u0418\u043d\u0430\u0447\u0435 \u0442\u0438\u043d\u043a\u0435\u0440 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0451 \u0440\u0430\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043d\u043a\u0435\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c. \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <strong>jobs <\/strong>\u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0417\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b jobs<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u043b\u044f <strong>available_at<\/strong> \u0438 <strong>created_at<\/strong> \u0440\u0430\u0432\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/www.php.net\/manual\/ru\/function.time.php\" rel=\"noopener noreferrer nofollow\">time()<\/a> \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u042d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u043a\u0443\u043d\u0434, \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0445 \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u044d\u043f\u043e\u0445\u0438 Unix (1 \u044f\u043d\u0432\u0430\u0440\u044f 1970 00:00:00 GMT) \u0434\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>\u041f\u043e\u043b\u0435 <strong>payload<\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 json, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f.<\/p>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u0442\u0438\u043d\u043a\u0435\u0440, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c<\/p>\n<pre><code class=\"php\">json_decode(\\DB::table('jobs')->first()->payload);<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"php\">> json_decode(\\DB::table('jobs')->first()->payload); = {#6275     +\"uuid\": \"0c2c7167-804a-4bed-9991-8827571f6be8\",     +\"displayName\": \"App\\Jobs\\TestJob\",     +\"job\": \"Illuminate\\Queue\\CallQueuedHandler@call\",     +\"maxTries\": null,     +\"maxExceptions\": null,     +\"failOnTimeout\": false,     +\"backoff\": null,     +\"timeout\": null,     +\"retryUntil\": null,     +\"data\": {#6298       +\"commandName\": \"App\\Jobs\\TestJob\",       +\"command\": \"O:16:\"App\\Jobs\\TestJob\":3:{s:5:\"email\";s:12:\"tset@liam.ur\";s:7:\"subject\";s:12:\"Subject Test\";s:2:\"id\";i:654321;}\",     },   } <\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 json \u0432 PostgreSQL \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 data->command, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <abbr class=\"habraabbr\" title=\"\" data-title=\"&lt;p>&lt;\/p>&#187; data-abbr=&#187;App\\Jobs\\TestJob&#187;>App\\Jobs\\TestJob<\/abbr><\/p>\n<p>\u041f\u043e\u0434\u0430\u0451\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 tinker<\/p>\n<pre><code class=\"php\">unserialize(json_decode(\\DB::table('jobs')->first()->payload)->data->command);<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c<\/p>\n<pre><code class=\"php\">> unserialize(json_decode(\\DB::table('jobs')->first()->payload)->data->command); = App\\Jobs\\TestJob {#6318       +email: \"tset@liam.ur\",     +subject: \"Subject Test\",     +id: 654321,     +job: null,     +connection: null,     +queue: null,     +chainConnection: null,     +chainQueue: null,     +chainCatchCallbacks: null,     +delay: null,     +afterCommit: null,     +middleware: [],     +chained: [],   } <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e PostgreSQL \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b PHP \u0438 \u043e\u0431 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0438\u043d\u044f\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u044d\u0442\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u043a\u0430\u043a \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0439. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 PostgreSQL<\/p>\n<p><a class=\"anchor\" name=\"insert_record\" id=\"insert_record\"><\/a><\/p>\n<h2>\u0412\u0441\u0442\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 jobs \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 PostgreSQL<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 jobs \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c uuid<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u043a\u0443\u043d\u0434, \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0445 \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u044d\u043f\u043e\u0445\u0438 Unix (1 \u044f\u043d\u0432\u0430\u0440\u044f 1970 00:00:00 GMT) \u0434\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/p>\n<\/li>\n<li>\n<p>\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c json, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0435<\/p>\n<\/li>\n<\/ul>\n<h3>\u0423\u0447\u0438\u043c PostgreSQL \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c uuid<\/h3>\n<h4>\u0414\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0438 13 \u0438 \u0432\u044b\u0448\u0435<\/h4>\n<p>PostgreSQL \u0432\u0435\u0440\u0441\u0438\u0438 13 \u0438 \u0432\u044b\u0448\u0435 \u0443\u043c\u0435\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c uuid v 4 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438.<\/p>\n<pre><code class=\"sql\">SELECT gen_random_uuid();<\/code><\/pre>\n<pre><code>           gen_random_uuid             --------------------------------------  5a103975-1419-4a4b-9afb-a4743f3d54a3<\/code><\/pre>\n<h4>\u0414\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0438\u0436\u0435 13<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c uuid \u0432 PostgreSQL \u043d\u0438\u0436\u0435 13-\u0439 \u0432\u0435\u0440\u0441\u0438\u0438, \u043d\u0443\u0436\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435\u0441\u044f \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/15\/uuid-ossp\" rel=\"noopener noreferrer nofollow\">uuid-ossp<\/a>. \u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043e\u0442\u043a\u043b\u044e\u0447\u0451\u043d \u0438 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c. \u042f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043b\u0438 \u043d\u0443\u0436\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u043e\u043a\u0435\u0440-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435.<\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0441\u044c \u043a \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443<\/p>\n<pre><code class=\"bash\">docker container exec -it pgsql bash<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0441\u044c \u043a \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 PostgreSQL \u2014 psql<\/p>\n<pre><code class=\"bash\"># psql -U test<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u044e, \u043a\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b<\/p>\n<pre><code class=\"sql\">test=# \\df                        List of functions  Schema | Name | Result data type | Argument data types | Type --------+------+------------------+---------------------+------ (0 rows)<\/code><\/pre>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 uuid \u043d\u0435\u0442. \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c.<\/p>\n<pre><code class=\"sql\">test=# CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\"; CREATE EXTENSION test-# \\df                                  List of functions  Schema |        Name        | Result data type |    Argument data types    | Type --------+--------------------+------------------+---------------------------+------  public | uuid_generate_v1   | uuid             |                           | func  public | uuid_generate_v1mc | uuid             |                           | func  public | uuid_generate_v3   | uuid             | namespace uuid, name text | func  public | uuid_generate_v4   | uuid             |                           | func  public | uuid_generate_v5   | uuid             | namespace uuid, name text |<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\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-357757","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/357757","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=357757"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/357757\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=357757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=357757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=357757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}