{"id":482994,"date":"2026-06-09T12:09:41","date_gmt":"2026-06-09T12:09:41","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=482994"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=482994","title":{"rendered":"\u041f\u0438\u0448\u0435\u043c \u0430\u0432\u0442\u043e\u043c\u0438\u0433\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 Go: \u043a\u0430\u043a \u0443\u0437\u043d\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 PostgreSQL"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u00ab\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439\u00bb, \u043e\u0431\u044b\u0447\u043d\u043e \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<pre><code class=\"sql\">CREATE TABLE users (\u00a0 \u00a0 id BIGSERIAL PRIMARY KEY,\u00a0 \u00a0 email TEXT NOT NULL);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0441 <code>CREATE TABLE<\/code>. \u041e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043c\u0435\u043d\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u043d\u043e\u0433\u043e, \u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430:<\/p>\n<blockquote>\n<p>\u041a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0431\u0430\u0437\u044b \u0432 \u043a\u043e\u0434\u0435?<\/p>\n<\/blockquote>\n<p>\u041f\u043e\u043a\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0447\u0442\u0438 \u043d\u0438\u0447\u0435\u0433\u043e:<\/p>\n<ul>\n<li>\n<p>\u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0431\u0430\u0437\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c diff \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 <code>ALTER TABLE<\/code>, <code>CREATE INDEX<\/code> \u0438 <code>DROP CONSTRAINT<\/code> \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u044f \u0431\u0443\u0434\u0443 \u0438\u0434\u0442\u0438 \u043a \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043d\u0430 Go \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 Go. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c <strong>\u0441\u0445\u0435\u043c\u0443 PostgreSQL<\/strong> \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0435\u0433\u043e \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e Go-\u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0443\u044e:<\/p>\n<pre><code class=\"go\">type Schema struct {\u00a0 \u00a0 Tables []Table}type Table struct {\u00a0 \u00a0 Schema \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 Name \u00a0 \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 Columns \u00a0 \u00a0 []Column\u00a0 \u00a0 Constraints []Constraint\u00a0 \u00a0 Indexes \u00a0 \u00a0 []Index}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u0447\u0430\u0441\u0442\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/SennovE\/qrafter\" rel=\"noopener noreferrer nofollow\">qrafter<\/a>: \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0443\u0436\u0435 \u0443\u043c\u0435\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 DDL-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0430 \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>Schema<\/code>, <code>Table<\/code>, <code>Column<\/code>, <code>Constraint<\/code>, <code>Index<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 <code>ddl.Statements<\/code>.<\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u0438\u0437 \u0431\u0430\u0437\u044b<\/h2>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0436\u0438\u0432\u0451\u0442 \u0443\u0436\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442.<\/p>\n<p>\u0412 \u0431\u0430\u0437\u0435 \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0438, \u043a\u0430\u043a\u0438\u0435-\u0442\u043e <code>default now()<\/code>, \u043f\u0430\u0440\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0442\u043e-\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443 \u0432\u0435\u0447\u0435\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u0434 \u0440\u0435\u043b\u0438\u0437\u043e\u043c.<\/p>\n<p>\u0418 \u0432\u043e\u0442 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p> \u0412\u043e\u0442 \u0447\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0431\u0430\u0437\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0442 \u0447\u0435\u043c \u043e\u043d\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0445\u0435\u043c\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u043e\u0435\u043a\u0442 \u0440\u0430\u0441\u0442\u0435\u0442 \u0438 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: \u0432\u0437\u044f\u0442\u044c <code>pg_dump --schema-only<\/code>, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c SQL \u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0438\u0442\u044c.<\/p>\n<p>\u0417\u0432\u0443\u0447\u0438\u0442 \u0437\u0430\u043c\u0430\u043d\u0447\u0438\u0432\u043e. \u041d\u043e \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0431\u043e\u043b\u043e\u0442\u043e.<\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e SQL-\u0442\u0435\u043a\u0441\u0442 \u2014 \u044d\u0442\u043e \u043d\u0435 \u043c\u043e\u0434\u0435\u043b\u044c. \u042d\u0442\u043e \u0443\u0436\u0435 \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u0414\u0432\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 SQL \u043c\u043e\u0433\u0443\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0441\u0445\u0435\u043c\u0443:<\/p>\n<pre><code class=\"sql\">CREATE UNIQUE INDEX users_email_idx ON users USING btree (email);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<pre><code class=\"sql\">CREATE UNIQUE INDEX users_email_idx ON public.users (email);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435. \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e diff-\u0430 \u2014 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b.<\/p>\n<p>\u0410 \u0435\u0449\u0451 <code>pg_dump<\/code> \u0445\u043e\u0440\u043e\u0448 \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u044b, \u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d \u0431\u044b\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u043c AST \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0438\u0433\u0440\u0430\u0442\u043e\u0440\u0430. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043d\u044f SQL, \u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/p>\n<pre><code class=\"go\">Table{\u00a0 \u00a0 Schema: \"public\",\u00a0 \u00a0 Name: \u00a0 \"users\",\u00a0 \u00a0 Columns: []Column{\u00a0 \u00a0 \u00a0 \u00a0 {Name: \"id\", DatabaseType: \"bigint\", NotNull: true, ...},\u00a0 \u00a0 \u00a0 \u00a0 {Name: \"email\", DatabaseType: \"character varying(320)\", NotNull: true, ...},\u00a0 \u00a0 },\u00a0 \u00a0 Constraints: []Constraint{\u00a0 \u00a0 \u00a0 \u00a0 {Kind: ConstraintPrimaryKey, Columns: []string{\"id\"}, ...},\u00a0 \u00a0 \u00a0 \u00a0 {Kind: ConstraintUnique, Columns: []string{\"email\"}, ...},\u00a0 \u00a0 },}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u0437 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c: \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0432 DDL.<\/p>\n<hr\/>\n<h3>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u043e\u0439<\/h3>\n<p>PostgreSQL \u0431\u043e\u043b\u044c\u0448\u043e\u0439. \u041e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0451, \u0441\u0442\u0430\u0442\u044c\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 <code>pg_depend<\/code>, <code>pg_rewrite<\/code>, RLS policies \u0438 \u0442\u0438\u0445\u043e\u0433\u043e \u043e\u0442\u0447\u0430\u044f\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e.<\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0447\u0438\u0442\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0441\u0445\u0435\u043c\u044b PostgreSQL;<\/p>\n<\/li>\n<li>\n<p>\u0442\u0430\u0431\u043b\u0438\u0446\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u043b\u043e\u043d\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0442\u0438\u043f\u044b \u043a\u043e\u043b\u043e\u043d\u043e\u043a;<\/p>\n<\/li>\n<li>\n<p>NOT NULL;<\/p>\n<\/li>\n<li>\n<p>default expressions;<\/p>\n<\/li>\n<li>\n<p>primary key;<\/p>\n<\/li>\n<li>\n<p>unique constraints;<\/p>\n<\/li>\n<li>\n<p>foreign keys;<\/p>\n<\/li>\n<li>\n<p>indexes.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043a\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0437\u0430 \u043a\u0430\u0434\u0440\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>views;<\/p>\n<\/li>\n<li>\n<p>materialized views;<\/p>\n<\/li>\n<li>\n<p>triggers;<\/p>\n<\/li>\n<li>\n<p>functions;<\/p>\n<\/li>\n<li>\n<p>enum\/domain types \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>partitions;<\/p>\n<\/li>\n<li>\n<p>policies\/RLS;<\/p>\n<\/li>\n<li>\n<p>comments;<\/p>\n<\/li>\n<li>\n<p>extensions;<\/p>\n<\/li>\n<li>\n<p>privileges;<\/p>\n<\/li>\n<li>\n<p>sequences \u043a\u0430\u043a \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>exclusion constraints;<\/p>\n<\/li>\n<li>\n<p>storage options;<\/p>\n<\/li>\n<li>\n<p>tablespaces, \u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u043d\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0435 \u0432\u0430\u0436\u043d\u044b. \u041d\u0430\u043e\u0431\u043e\u0440\u043e\u0442: \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f PostgreSQL, \u0440\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u0442\u0443\u0434\u0430 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u0438\u0439\u0442\u0438. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0430\u0432\u0442\u043e\u043c\u0438\u0433\u0440\u0430\u0442\u043e\u0440\u0430 \u2014 \u043d\u0435 \u0441\u0442\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u044b\u043c <code>pg_dump<\/code>, \u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439, \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 snapshot.<\/p>\n<hr\/>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e information_schema?<\/h3>\n<p>\u0412 PostgreSQL \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p><code>information_schema<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>pg_catalog<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p><code>information_schema<\/code> \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043b\u043e\u0439. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 PostgreSQL \u043f\u0440\u044f\u043c\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e information schema \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 SQL-\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u043e\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u0430 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430, \u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 PostgreSQL \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u0430\u043c \u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u043e\u0435 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u0435: PostgreSQL-\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 information schema \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0434\u043b\u044f \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438.<\/p>\n<p>\u0417\u0432\u0443\u0447\u0438\u0442 \u0442\u0430\u043a, \u0431\u0443\u0434\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>information_schema<\/code>.<\/p>\n<p>\u041d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<blockquote>\n<p><strong>information_schema<\/strong> \u2014 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u044f<\/p>\n<p><strong>pg_catalog <\/strong>\u2014 \u043d\u0443\u0436\u0435\u043d \u0442\u0430\u043c, \u0433\u0434\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 PostgreSQL<\/p>\n<\/blockquote>\n<p>\u0414\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a <code>information_schema<\/code> \u043f\u0440\u0438\u044f\u0442\u043d\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>information_schema.columns<\/code> \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b, \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043f\u043e\u0437\u0438\u0446\u0438\u044e, default expression, nullability, \u0442\u0438\u043f, identity\/generated-\u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u0438\u043f\u0430\u0445.<\/p>\n<p>\u041d\u043e \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043f\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c, \u0442\u043e\u0447\u043d\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0438\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 PostgreSQL-\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u2014 \u0438\u0434\u0451\u043c \u0432 <code>pg_catalog<\/code>.<\/p>\n<hr\/>\n<h3>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0445\u0435\u043c\u044b \u0432 Go<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0434 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043a\u0443\u0447\u043d\u0443\u044e, \u043d\u043e \u0432\u0430\u0436\u043d\u0443\u044e \u0432\u0435\u0449\u044c: \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0438\u043d\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0442\u043e\u0440 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432 \u043d\u0430\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <code>loadSomething<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 DTO, \u0430 \u043f\u043e\u0442\u043e\u043c \u0433\u0434\u0435-\u0442\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u0441\u0451 \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0447\u0435\u0441\u0442\u043d\u043e\u043c \u0441\u043b\u043e\u0432\u0435.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"go\">type Schema struct {\u00a0 \u00a0 Tables []Table}type Table struct {\u00a0 \u00a0 Schema \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 Name \u00a0 \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 Columns \u00a0 \u00a0 []Column\u00a0 \u00a0 Constraints []Constraint\u00a0 \u00a0 Indexes \u00a0 \u00a0 []Index}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u043e\u043b\u043e\u043d\u043a\u0430:<\/p>\n<pre><code class=\"go\">type Column struct {\u00a0 \u00a0 Schema \u00a0 \u00a0    string\u00a0 \u00a0 TableName     string\u00a0 \u00a0 Position \u00a0    int\u00a0 \u00a0 Name \u00a0 \u00a0 \u00a0 \u00a0  string\u00a0 \u00a0 DatabaseType  string\u00a0 \u00a0 NotNull       bool\u00a0 \u00a0 HasDefault    bool\u00a0 \u00a0 DefaultExpr   string\u00a0 \u00a0 Identity \u00a0 \u00a0 \u00a0IdentityKind\u00a0 \u00a0 Generated \u00a0 \u00a0 GeneratedKind\u00a0 \u00a0 GeneratedExpr string}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Constraint:<\/p>\n<pre><code class=\"go\">type ConstraintKind stringconst (\u00a0 \u00a0 ConstraintPrimaryKey ConstraintKind = \"primary_key\"\u00a0 \u00a0 ConstraintUnique \u00a0 \u00a0 ConstraintKind = \"unique\"\u00a0 \u00a0 ConstraintCheck \u00a0 \u00a0 \u00a0ConstraintKind = \"check\"\u00a0 \u00a0 ConstraintForeignKey ConstraintKind = \"foreign_key\")type Reference struct {\u00a0 \u00a0 Schema \u00a0 \u00a0string\u00a0 \u00a0 TableName string\u00a0 \u00a0 Columns \u00a0 []string}type Constraint struct {\u00a0 \u00a0 Schema \u00a0 \u00a0string\u00a0 \u00a0 TableName string\u00a0 \u00a0 Name      string\u00a0 \u00a0 Kind      ConstraintKind\u00a0 \u00a0 Columns   []string\u00a0 \u00a0 CheckExpr string\u00a0 \u00a0 Reference Reference\u00a0 \u00a0 OnDelete \u00a0string\u00a0 \u00a0 OnUpdate \u00a0string}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u043d\u0434\u0435\u043a\u0441:<\/p>\n<pre><code class=\"go\">type IndexKey struct {\u00a0 \u00a0 \/\/ \u0414\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438:\u00a0 \u00a0 \/\/ \"email\"\u00a0 \u00a0 \/\/\u00a0 \u00a0 \/\/ \u0414\u043b\u044f expression index:\u00a0 \u00a0 \/\/ \"lower(email)\"\u00a0 \u00a0 Expression string}type Index struct {\u00a0 \u00a0 Schema \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 TableSchema string\u00a0 \u00a0 TableName \u00a0 string\u00a0 \u00a0 Name \u00a0      string\u00a0 \u00a0 Unique      bool\u00a0 \u00a0 Method      string\u00a0 \u00a0 Keys        []IndexKey\u00a0 \u00a0 Include     []string\u00a0 \u00a0 Predicate   string \/\/ partial index: where ...}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 <code>qrafter<\/code> \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0445\u043e\u0436\u0430\u044f, \u043d\u043e \u0443\u0436\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 <code>ddl<\/code>-\u043f\u0430\u043a\u0435\u0442\u043e\u043c: <code>Column<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 <code>ddl.Type<\/code>, <code>Constraint<\/code> \u0443\u043c\u0435\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 <code>ddl.TableConstraint<\/code>, \u0430 <code>Index<\/code> \u2014 \u0432 <code>ddl.CreateIndexStmt<\/code>. \u0423 <code>Schema.DDL()<\/code> \u0435\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f <code>CREATE TABLE<\/code>, \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e <code>CREATE TABLE<\/code>.<\/p>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043c\u044b\u0441\u043b\u044c: \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0431\u0449\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u0432 PostgreSQL \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430, \u043d\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 PostgreSQL.<\/p>\n<p>\u041f\u043b\u043e\u0445\u0430\u044f \u0438\u0434\u0435\u044f:<\/p>\n<pre><code class=\"go\">type Column struct {\u00a0 \u00a0 Name string\u00a0 \u00a0 Type string}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code class=\"go\">type Column struct {\u00a0 \u00a0 Name string\u00a0 \u00a0 \/\/ \u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 DDL.\u00a0 \u00a0 Type ddl.Type\u00a0 \u00a0 \/\/ \u0422\u043e, \u0447\u0442\u043e \u0432\u0435\u0440\u043d\u0443\u043b\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f \u0431\u0430\u0437\u0430.\u00a0 \u00a0 DatabaseType string\u00a0 \u00a0 \/\/ PostgreSQL-specific \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.\u00a0 \u00a0 Raw map[string]string}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0421\u0423\u0411\u0414 \u043e\u0431\u044b\u0447\u043d\u043e \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043d\u0430 <code>CREATE TABLE users<\/code>, \u0430 \u043d\u0430 \u043c\u0435\u043b\u043e\u0447\u0430\u0445:<\/p>\n<ul>\n<li>\n<p><code>serial<\/code> vs <code>identity<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>timestamp with time zone<\/code> vs <code>datetime<\/code>;<\/p>\n<\/li>\n<li>\n<p>partial indexes;<\/p>\n<\/li>\n<li>\n<p>generated columns;<\/p>\n<\/li>\n<li>\n<p><code>ON DELETE SET NULL<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>NULLS NOT DISTINCT<\/code> \u0443 unique indexes;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043a\u0430\u0432\u044b\u0447\u0435\u043a \u0438 placeholder-\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 <code>qrafter<\/code> \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u044b PostgreSQL, MySQL, SQLite, Oracle \u0438 SQL Server, \u0430 DDL-\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0421\u0423\u0411\u0414. \u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b: introspection \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c PostgreSQL-first, \u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u044b.<\/p>\n<hr\/>\n<h3>\u0427\u0438\u0442\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e: \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<p>\u0427\u0435\u0440\u0435\u0437 <code>information_schema<\/code> \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">SELECT\u00a0 \u00a0 table_schema, -- \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u00a0 \u00a0 table_name \u00a0 \u00a0-- \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044bFROM information_schema.tables-- \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\/viewWHERE table_type = 'BASE TABLE'  -- \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0441\u0445\u0435\u043c\u044b PostgreSQL\u00a0 AND table_schema NOT IN ('pg_catalog', 'information_schema')ORDER BY table_schema, table_name;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">table_schema<\/p>\n<\/td>\n<td>\n<p align=\"left\">table_name<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">public<\/p>\n<\/td>\n<td>\n<p align=\"left\">customers<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">public<\/p>\n<\/td>\n<td>\n<p align=\"left\">order_items<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">sales<\/p>\n<\/td>\n<td>\n<p align=\"left\">payments<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/details>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0439\u0442\u0438 PostgreSQL-way, \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0447\u0435\u0440\u0435\u0437 <code>pg_class<\/code> \u0438 <code>pg_namespace<\/code>:<\/p>\n<pre><code class=\"sql\">SELECT\u00a0 \u00a0 n.nspname AS table_schema, -- \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u00a0 \u00a0 c.relname AS table_name, \u00a0 -- \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u00a0 \u00a0 c.oid \u00a0 \u00a0 AS table_oid \u00a0 \u00a0 -- \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 OID \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 PostgreSQL-- \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 PostgreSQL \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438-\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u043c\u0438: \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438, view \u0438 \u0442.\u0434.FROM pg_catalog.pg_class c-- \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c \u0441\u0445\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b \u043f\u043e OIDJOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace-- \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b ('r') \u0438 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b ('p')WHERE c.relkind IN ('r', 'p')  -- \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0441\u0445\u0435\u043c\u044b\u00a0 AND n.nspname NOT IN ('pg_catalog', 'information_schema')  -- \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c TOAST-\u0441\u0445\u0435\u043c\u044b PostgreSQL \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439\u00a0 AND n.nspname NOT LIKE 'pg_toast%'ORDER BY n.nspname, c.relname;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"> table_schema<\/p>\n<\/td>\n<td>\n<p align=\"left\">table_name<\/p>\n<\/td>\n<td>\n<p align=\"left\">table_oid<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">public<\/p>\n<\/td>\n<td>\n<p align=\"left\">customers<\/p>\n<\/td>\n<td>\n<p align=\"left\"> 16421<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">sales<\/p>\n<\/td>\n<td>\n<p align=\"left\">payments<\/p>\n<\/td>\n<td>\n<p align=\"left\"> 16433<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/details>\n<p><code>pg_class<\/code> \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u044b: \u0438\u043d\u0434\u0435\u043a\u0441\u044b, sequences, views, materialized views, composite types \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 relation-like \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u041f\u043e\u043b\u0435 <code>relkind<\/code> \u043a\u0430\u043a \u0440\u0430\u0437 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b, sequences, views, partitioned tables \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<hr\/>\n<h3>\u0427\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u043e\u043d\u043a\u0438<\/h3>\n<p>\u041a\u043e\u043b\u043e\u043d\u043a\u0438 \u0442\u043e\u0436\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 <code>information_schema.columns<\/code>:<\/p>\n<p>&#171;`<\/p>\n<pre><code class=\"sql\">SELECT\u00a0 \u00a0 table_schema, -- \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u00a0 \u00a0 table_name, -- \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u00a0 \u00a0 column_name, -- \u0438\u043c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438\u00a0 \u00a0 ordinal_position, -- \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u00a0 \u00a0 is_nullable, -- \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c NULL: YES \u0438\u043b\u0438 NO\u00a0 \u00a0 data_type, -- \u043e\u0431\u0449\u0438\u0439 SQL-\u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043a\u0438\u00a0 \u00a0 udt_schema, -- \u0441\u0445\u0435\u043c\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e PostgreSQL-\u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445\u00a0 \u00a0 udt_name, -- \u0438\u043c\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e PostgreSQL-\u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445\u00a0 \u00a0 character_maximum_length, -- \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, varchar(255)\u00a0 \u00a0 numeric_precision, -- \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432: \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0446\u0438\u0444\u0440\u00a0 \u00a0 numeric_scale, -- \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0434\u043b\u044f \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u044f\u0442\u043e\u0439\u00a0 \u00a0 datetime_precision, -- \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u043d\u0430\u043a\u043e\u0432 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u00a0 \u00a0 column_default, -- \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u043e\u00a0 \u00a0 is_identity, -- \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 identity-\u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439: YES \u0438\u043b\u0438 NO\u00a0 \u00a0 identity_generation, -- \u0441\u043f\u043e\u0441\u043e\u0431 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 identity-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f: ALWAYS \u0438\u043b\u0438 BY DEFAULT\u00a0 \u00a0 is_generated, -- \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439\u00a0 \u00a0 generation_expression -- \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430FROM information_schema.columns -- \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f\u043c\u0438 \u043e \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u0445 \u0442\u0430\u0431\u043b\u0438\u0446-- \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0441\u0445\u0435\u043c\u044b PostgreSQLWHERE table_schema NOT IN ('pg_catalog', 'information_schema') ORDER BY table_schema, table_name, ordinal_position;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"139\" width=\"139\">\n<p align=\"left\">table_schema<\/p>\n<\/td>\n<td data-colwidth=\"129\" width=\"129\">\n<p align=\"left\">table_name<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">column_name<\/p>\n<\/td>\n<td data-colwidth=\"147\" width=\"147\">\n<p align=\"left\">ordinal_position<\/p>\n<\/td>\n<td data-colwidth=\"116\" width=\"116\">\n<p align=\"left\">is_nullable<\/p>\n<\/td>\n<td data-colwidth=\"233\" width=\"233\">\n<p align=\"left\">data_type  <\/p>\n<\/td>\n<td data-colwidth=\"121\" width=\"121\">\n<p align=\"left\">udt_schema  <\/p>\n<\/td>\n<td data-colwidth=\"109\" width=\"109\">\n<p align=\"left\">udt_name<\/p>\n<\/td>\n<td data-colwidth=\"230\" width=\"230\">\n<p align=\"left\">character_maximum_length<\/p>\n<\/td>\n<td data-colwidth=\"171\" width=\"171\">\n<p align=\"left\">numeric_precision<\/p>\n<\/td>\n<td data-colwidth=\"161\" width=\"161\">\n<p align=\"left\">numeric_scale  <\/p>\n<\/td>\n<td data-colwidth=\"166\" width=\"166\">\n<p align=\"left\">datetime_precision  <\/p>\n<\/td>\n<td data-colwidth=\"299\" width=\"299\">\n<p align=\"left\">column_default<\/p>\n<\/td>\n<td>\n<p align=\"left\">is_identity<\/p>\n<\/td>\n<td data-colwidth=\"170\" width=\"170\">\n<p align=\"left\">identity_generation<\/p>\n<\/td>\n<td data-colwidth=\"149\" width=\"149\">\n<p align=\"left\">is_generated<\/p>\n<\/td>\n<td data-colwidth=\"195\" width=\"195\">\n<p align=\"left\">generation_expression<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"139\" width=\"139\">\n<p align=\"left\">public<\/p>\n<\/td>\n<td data-colwidth=\"129\" width=\"129\">\n<p align=\"left\">customers<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">id<\/p>\n<\/td>\n<td data-colwidth=\"147\" width=\"147\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"116\" width=\"116\">\n<p align=\"left\">NO<\/p>\n<\/td>\n<td data-colwidth=\"233\" width=\"233\">\n<p align=\"left\">integer<\/p>\n<\/td>\n<td data-colwidth=\"121\" width=\"121\">\n<p align=\"left\">pg_catalog<\/p>\n<\/td>\n<td data-colwidth=\"109\" width=\"109\">\n<p align=\"left\">int4<\/p>\n<\/td>\n<td data-colwidth=\"230\" width=\"230\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"171\" width=\"171\">\n<p align=\"left\">32<\/p>\n<\/td>\n<td data-colwidth=\"161\" width=\"161\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"166\" width=\"166\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"299\" width=\"299\">\n<p align=\"left\">nextval(&#8216;customers_id_seq&#8217;::regclass)<\/p>\n<\/td>\n<td>\n<p align=\"left\">NO<\/p>\n<\/td>\n<td data-colwidth=\"170\" width=\"170\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"149\" width=\"149\">\n<p align=\"left\">NEVER<\/p>\n<\/td>\n<td data-colwidth=\"195\" width=\"195\">\n<p align=\"left\">\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"139\" width=\"139\">\n<p align=\"left\">public<\/p>\n<\/td>\n<td data-colwidth=\"129\" width=\"129\">\n<p align=\"left\">customers<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">name<\/p>\n<\/td>\n<td data-colwidth=\"147\" width=\"147\">\n<p align=\"left\">2<\/p>\n<\/td>\n<td data-colwidth=\"116\" width=\"116\">\n<p align=\"left\">YES<\/p>\n<\/td>\n<td data-colwidth=\"233\" width=\"233\">\n<p align=\"left\">character varying<\/p>\n<\/td>\n<td data-colwidth=\"121\" width=\"121\">\n<p align=\"left\">pg_catalog<\/p>\n<\/td>\n<td data-colwidth=\"109\" width=\"109\">\n<p align=\"left\"> varchar<\/p>\n<\/td>\n<td data-colwidth=\"230\" width=\"230\">\n<p align=\"left\">255<\/p>\n<\/td>\n<td data-colwidth=\"171\" width=\"171\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"161\" width=\"161\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"166\" width=\"166\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"299\" width=\"299\">\n<p align=\"left\">\n<\/td>\n<td>\n<p align=\"left\">NO<\/p>\n<\/td>\n<td data-colwidth=\"170\" width=\"170\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"149\" width=\"149\">\n<p align=\"left\">NEVER<\/p>\n<\/td>\n<td data-colwidth=\"195\" width=\"195\">\n<p align=\"left\">\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"139\" width=\"139\">\n<p align=\"left\">public<\/p>\n<\/td>\n<td data-colwidth=\"129\" width=\"129\">\n<p align=\"left\">customers<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">email<\/p>\n<\/td>\n<td data-colwidth=\"147\" width=\"147\">\n<p align=\"left\">3<\/p>\n<\/td>\n<td data-colwidth=\"116\" width=\"116\">\n<p align=\"left\">NO<\/p>\n<\/td>\n<td data-colwidth=\"233\" width=\"233\">\n<p align=\"left\">character varying<\/p>\n<\/td>\n<td data-colwidth=\"121\" width=\"121\">\n<p>pg_catalog<\/p>\n<\/td>\n<td data-colwidth=\"109\" width=\"109\">\n<p align=\"left\">varchar<\/p>\n<\/td>\n<td data-colwidth=\"230\" width=\"230\">\n<p align=\"left\">320<\/p>\n<\/td>\n<td data-colwidth=\"171\" width=\"171\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"161\" width=\"161\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"166\" width=\"166\">\n<p align=\"left\">6<\/p>\n<\/td>\n<td data-colwidth=\"299\" width=\"299\">\n<p align=\"left\"> now()<\/p>\n<\/td>\n<td>\n<p align=\"left\">NO<\/p>\n<\/td>\n<td data-colwidth=\"170\" width=\"170\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"149\" width=\"149\">\n<p align=\"left\">NEVER<\/p>\n<\/td>\n<td data-colwidth=\"195\" width=\"195\">\n<p align=\"left\">\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"139\" width=\"139\">\n<p align=\"left\">public<\/p>\n<\/td>\n<td data-colwidth=\"129\" width=\"129\">\n<p align=\"left\">customers<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">created_at<\/p>\n<\/td>\n<td data-colwidth=\"147\" width=\"147\">\n<p align=\"left\">4<\/p>\n<\/td>\n<td data-colwidth=\"116\" width=\"116\">\n<p align=\"left\">NO<\/p>\n<\/td>\n<td data-colwidth=\"233\" width=\"233\">\n<p align=\"left\">timestamp without time zone<\/p>\n<\/td>\n<td data-colwidth=\"121\" width=\"121\">\n<p align=\"left\">pg_catalog<\/p>\n<\/td>\n<td data-colwidth=\"109\" width=\"109\">\n<p align=\"left\"> timestamp  <\/p>\n<\/td>\n<td data-colwidth=\"230\" width=\"230\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"171\" width=\"171\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"161\" width=\"161\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"166\" width=\"166\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"299\" width=\"299\">\n<p align=\"left\">\n<\/td>\n<td>\n<p align=\"left\">NO<\/p>\n<\/td>\n<td data-colwidth=\"170\" width=\"170\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"149\" width=\"149\">\n<p align=\"left\">NEVER<\/p>\n<\/td>\n<td data-colwidth=\"195\" width=\"195\">\n<p align=\"left\">\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/details>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u043e\u0431\u043c\u0430\u043d\u0443\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0435\u043c <code>data_type<\/code>.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e <code>text<\/code> \u043e\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u0414\u043b\u044f <code>integer<\/code> \u0442\u043e\u0436\u0435. \u041d\u043e PostgreSQL-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e <code>data_type<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <code>ARRAY<\/code> \u0434\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438\u043b\u0438 <code>USER-DEFINED<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u0430 \u0434\u043b\u044f domain-\u0442\u0438\u043f\u043e\u0432 <code>data_type<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 underlying type, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a domain \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e <code>data_type<\/code>, \u043d\u043e \u0438 <code>udt_schema<\/code> \/ <code>udt_name<\/code>, \u0430 \u0435\u0449\u0451 \u0434\u043b\u0438\u043d\u0443, precision \u0438 scale.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>varchar(320)<\/code> \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e <code>character varying<\/code>. \u041d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0440\u0430\u0437\u043c\u0435\u0440.<\/p>\n<p>\u041f\u043e\u0437\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 <code>pg_catalog.format_type(a.atttypid, a.atttypmod)<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e PostgreSQL \u0443\u0436\u0435 \u0443\u043c\u0435\u0435\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c SQL-\u0438\u043c\u044f \u0442\u0438\u043f\u0430 \u043f\u043e OID \u0438 typemod. \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>format_type<\/code> \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0441\u0440\u0435\u0434\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432.<\/p>\n<hr\/>\n<h3>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043b\u043e\u0432\u0443\u0448\u043a\u0430: bigserial \u2014 \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0442\u0438\u043f<\/h3>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0430:<\/p>\n<pre><code class=\"sql\">CREATE TABLE users (\u00a0 \u00a0 id BIGSERIAL PRIMARY KEY);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u0438\u043d\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0442\u043e\u0440 \u0432\u0435\u0440\u043d\u0451\u0442 \u0442\u0438\u043f <code>bigserial<\/code>.<\/p>\n<p>\u041d\u043e PostgreSQL \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0438\u043d\u0430\u0447\u0435: <code>smallserial<\/code>, <code>serial<\/code> \u0438 <code>bigserial<\/code> \u2014 \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0442\u0438\u043f\u044b, \u0430 \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0451\u0442 integer\/bigint-\u043a\u043e\u043b\u043e\u043d\u043a\u0443, sequence, default <code>nextval(...)<\/code> \u0438 ownership sequence \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u043a\u0443.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c snapshot \u043c\u043e\u0436\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<pre><code class=\"go\">Column{\u00a0 \u00a0 Name: \u00a0 \u00a0 \u00a0 \u00a0 \"id\",\u00a0 \u00a0 DatabaseType: \"bigint\",\u00a0 \u00a0 NotNull: \u00a0 \u00a0 \u00a0true,\u00a0 \u00a0 HasDefault: \u00a0 true,\u00a0 \u00a0 DefaultExpr: \u00a0\"nextval('users_id_seq'::regclass)\",}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0437\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u043e\u0439 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c: \u00ab\u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 <code>bigint<\/code>, default <code>nextval(...)<\/code>, sequence owned by \u044d\u0442\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439 \u2014 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u043e \u043a\u0430\u043a <code>bigserial<\/code>\u00bb. \u041d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0430 \u043d\u0435 \u0444\u0430\u043a\u0442 \u0438\u0437 <code>information_schema.columns<\/code>.<\/p>\n<hr\/>\n<h3>\u041a\u043e\u0433\u0434\u0430 portable SQL \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c PostgreSQL.<\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 PostgreSQL \u2014 \u044d\u0442\u043e \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u0421\u0423\u0411\u0414 \u0445\u0440\u0430\u043d\u0438\u0442 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0445\u0435\u043c\u044b: \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e\u0434\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b PostgreSQL, \u043d\u043e \u0440\u0443\u043a\u0430\u043c\u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445 \u043d\u0435 \u043d\u0430\u0434\u043e: \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c SQL-\u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<p>\u0413\u043b\u0430\u0432\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u043d\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0442\u043e\u0440\u0430:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"316\" width=\"316\">\n<p align=\"left\">\u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e<\/p>\n<\/td>\n<td data-colwidth=\"288\" width=\"288\">\n<p align=\"left\">\u0413\u0434\u0435 \u0438\u0441\u043a\u0430\u0442\u044c<\/p>\n<\/td>\n<td data-colwidth=\"259\" width=\"259\">\n<p align=\"left\">\u0427\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"316\" width=\"316\">\n<p align=\"left\">\u0421\u0445\u0435\u043c\u044b<\/p>\n<\/td>\n<td data-colwidth=\"288\" width=\"288\">\n<p align=\"left\"><code>pg_namespace<\/code><\/p>\n<\/td>\n<td data-colwidth=\"259\" width=\"259\">\n<p align=\"left\">namespaces, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043e\u0441\u043d\u043e\u0432\u0443 SQL-\u0441\u0445\u0435\u043c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"316\" width=\"316\">\n<p align=\"left\">\u0422\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b, sequences, views<\/p>\n<\/td>\n<td data-colwidth=\"288\" width=\"288\">\n<p align=\"left\"><code>pg_class<\/code><\/p>\n<\/td>\n<td data-colwidth=\"259\" width=\"259\">\n<p align=\"left\">\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"316\" width=\"316\">\n<p align=\"left\">\u041a\u043e\u043b\u043e\u043d\u043a\u0438<\/p>\n<\/td>\n<td data-colwidth=\"288\" width=\"288\">\n<p align=\"left\"><code>pg_attribute<\/code><\/p>\n<\/td>\n<td data-colwidth=\"259\" width=\"259\">\n<p align=\"left\">\u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"316\" width=\"316\">\n<p align=\"left\">\u0422\u0438\u043f\u044b<\/p>\n<\/td>\n<td data-colwidth=\"288\" width=\"288\">\n<p align=\"left\"><code>pg_type<\/code><\/p>\n<\/td>\n<td data-colwidth=\"259\" width=\"259\">\n<p align=\"left\">\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0438\u043f\u0430\u0445<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"316\" width=\"316\">\n<p align=\"left\">Default\/generated expressions<\/p>\n<\/td>\n<td data-colwidth=\"288\" width=\"288\">\n<p align=\"left\"><code>pg_attrdef<\/code><\/p>\n<\/td>\n<td data-colwidth=\"259\" width=\"259\">\n<p align=\"left\">default \u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043b\u043e\u043d\u043e\u043a<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"316\" width=\"316\">\n<p align=\"left\">Constraints<\/p>\n<\/td>\n<td data-colwidth=\"288\" width=\"288\">\n<p align=\"left\"><code>pg_constraint<\/code><\/p>\n<\/td>\n<td data-colwidth=\"259\" width=\"259\">\n<p align=\"left\">primary key, unique, foreign key, check \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0438\u043d\u0442\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"316\" width=\"316\">\n<p align=\"left\">\u0418\u043d\u0434\u0435\u043a\u0441\u044b<\/p>\n<\/td>\n<td data-colwidth=\"288\" width=\"288\">\n<p align=\"left\"><code>pg_index<\/code>, <code>pg_class<\/code>, <code>pg_am<\/code><\/p>\n<\/td>\n<td data-colwidth=\"259\" width=\"259\">\n<p align=\"left\"><code>pg_index<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0447\u0430\u0441\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043b\u0435\u0436\u0438\u0442 \u0432 <code>pg_class<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"316\" width=\"316\">\n<p align=\"left\">SQL-\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/td>\n<td data-colwidth=\"288\" width=\"288\">\n<p align=\"left\"><code>pg_get_expr(...)<\/code>, <code>pg_get_constraintdef(...)<\/code>, <code>pg_get_indexdef(...)<\/code><\/p>\n<\/td>\n<td data-colwidth=\"259\" width=\"259\">\n<p align=\"left\">\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0442\u043e\u0440 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0421\u0423\u0411\u0414 \u043d\u0435 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0437\u0430 \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u0423 \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0437\u044b \u0441\u0432\u043e\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u0438\u0440\u0430.<\/p>\n<hr\/>\n<h3>Constraints: \u043d\u0435 \u0441\u0442\u0440\u043e\u043a\u0430 SQL, \u0430 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430<\/h3>\n<p>\u0421 \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0438\u043d\u0442\u0430\u043c\u0438 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u043b\u043e\u0432\u0443\u0448\u043a\u0443.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c:<\/p>\n<pre><code class=\"sql\">SELECT pg_get_constraintdef(oid)FROM pg_constraint;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<pre><code class=\"sql\">PRIMARY KEY (id)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u043e \u0434\u043b\u044f diff-\u0430 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043b\u043e.<\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u00ab\u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 SQL\u00bb, \u0430 \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442:<\/p>\n<pre><code class=\"go\">Constraint{\u00a0 \u00a0 Name: \u00a0 \u00a0\"users_pkey\",\u00a0 \u00a0 Kind: \u00a0 \u00a0ConstraintPrimaryKey,\u00a0 \u00a0 Columns: []string{\"id\"},}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f foreign key:<\/p>\n<pre><code class=\"go\">Constraint{\u00a0 \u00a0 Name: \u00a0 \u00a0\"orders_user_id_fkey\",\u00a0 \u00a0 Kind: \u00a0 \u00a0ConstraintForeignKey,\u00a0 \u00a0 Columns: []string{\"user_id\"},\u00a0 \u00a0 Reference: Reference{\u00a0 \u00a0 \u00a0 \u00a0 Schema: \u00a0 \u00a0\"public\",\u00a0 \u00a0 \u00a0 \u00a0 TableName: \"users\",\u00a0 \u00a0 \u00a0 \u00a0 Columns: \u00a0 []string{\"id\"},\u00a0 \u00a0 },\u00a0 \u00a0 OnDelete: \"cascade\",\u00a0 \u00a0 OnUpdate: \"no_action\",}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e?<\/p>\n<p>\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u0432\u0435 SQL-\u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u043c\u0438, \u043d\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435. \u0410 \u0430\u0432\u0442\u043e\u043c\u0438\u0433\u0440\u0430\u0442\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441\u043c\u044b\u0441\u043b, \u0430 \u043d\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f constraints \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">SELECT    -- \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u00a0 \u00a0 ns.nspname AS table_schema,    -- \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u00a0 \u00a0 tbl.relname AS table_name,    -- \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 OID \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 PostgreSQL\u00a0 \u00a0 con.oid,    -- \u0438\u043c\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 users_pkey \u0438\u043b\u0438 orders_user_id_fkey\u00a0 \u00a0 con.conname,    -- \u0442\u0438\u043f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f: p = PRIMARY KEY, u = UNIQUE, f = FOREIGN KEY, c = CHECK\u00a0 \u00a0 con.contype, pg_get_constraintdef(con.oid, false) AS definition,    -- \u043f\u043e\u043b\u043d\u043e\u0435 SQL-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u043c \u0432\u0438\u0434\u0435\u00a0 \u00a0 ARRAY(        -- \u0438\u043c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u00a0 \u00a0 \u00a0 \u00a0 SELECT att.attname        -- \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u043e\u043c\u0435\u0440\u0430 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043a\u0430\u00a0 \u00a0 \u00a0 \u00a0 FROM unnest(con.conkey) WITH ordinality AS cols(attnum, ord)        -- \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 PostgreSQL \u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u00a0 \u00a0 \u00a0 \u00a0 JOIN pg_attribute att          -- \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0434\u0430\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ON att.attrelid = con.conrelid          -- \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0438\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u00a0 \u00a0 \u00a0 \u00a0 \u00a0AND att.attnum = cols.attnum        -- \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u00a0 \u00a0 \u00a0 \u00a0 ORDER BY cols.ord\u00a0 \u00a0 ) AS columns,    -- \u0441\u0445\u0435\u043c\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f FOREIGN KEY\u00a0 \u00a0 ref_ns.nspname AS ref_schema,    -- \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f FOREIGN KEY\u00a0 \u00a0 ref_tbl.relname AS ref_table,    -- \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f FOREIGN KEY\u00a0 \u00a0 ARRAY(        -- \u0438\u043c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f FOREIGN KEY\u00a0 \u00a0 \u00a0 \u00a0 SELECT att.attname         -- \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043a\u0430\u00a0 \u00a0 \u00a0 \u00a0 FROM unnest(con.confkey) WITH ordinality AS cols(attnum, ord)\u00a0 \u00a0 \u00a0 \u00a0 -- \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 PostgreSQL \u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446        JOIN pg_attribute att          -- \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ON att.attrelid = con.confrelid          -- \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u00a0 \u00a0 \u00a0 \u00a0 \u00a0AND att.attnum = cols.attnum\u00a0 \u00a0 \u00a0 \u00a0 ORDER BY cols.ord\u00a0 \u00a0 ) AS ref_columns,    -- \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 FOREIGN KEY \u043f\u0440\u0438 UPDATE: a = NO ACTION, r = RESTRICT, c = CASCADE, n = SET NULL, d = SET DEFAULT\u00a0 \u00a0 con.confupdtype,    -- \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 FOREIGN KEY \u043f\u0440\u0438 DELETE: a = NO ACTION, r = RESTRICT, c = CASCADE, n = SET NULL, d = SET DEFAULT\u00a0 \u00a0 con.confdeltype-- \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 PostgreSQL \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446FROM pg_constraint con-- \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c constraint \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u0437\u0430\u0434\u0430\u043dJOIN pg_class tbl ON tbl.oid = con.conrelid-- \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u043e \u0441\u0445\u0435\u043c\u043e\u0439JOIN pg_namespace ns ON ns.oid = tbl.relnamespace-- \u0434\u043b\u044f FOREIGN KEY \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0434\u0451\u0442 \u0441\u0441\u044b\u043b\u043a\u0430LEFT JOIN pg_class ref_tbl ON ref_tbl.oid = con.confrelid-- \u0434\u043b\u044f FOREIGN KEY \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0445\u0435\u043c\u0443 \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044bLEFT JOIN pg_namespace ref_ns ON ref_ns.oid = ref_tbl.relnamespace-- \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e PRIMARY KEY, UNIQUE, FOREIGN KEY \u0438 CHECKWHERE con.contype IN ('p', 'u', 'f', 'c')  -- \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0441\u0445\u0435\u043c\u044b PostgreSQL\u00a0 AND ns.nspname NOT IN ('pg_catalog', 'information_schema')ORDER BY ns.nspname, tbl.relname, con.conname;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 <code>pg_constraint.contype<\/code> PostgreSQL \u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0442\u0438\u043f constraint-\u0430: <code>p<\/code> \u0434\u043b\u044f primary key, <code>u<\/code> \u0434\u043b\u044f unique, <code>f<\/code> \u0434\u043b\u044f foreign key, <code>c<\/code> \u0434\u043b\u044f check, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u0440\u043e\u0434\u0435 not-null \u0438 exclusion. \u0422\u0430\u043c \u0436\u0435 \u043b\u0435\u0436\u0430\u0442 <code>confupdtype<\/code> \u0438 <code>confdeltype<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f foreign key \u043d\u0430 update\/delete.<\/p>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c: \u0438\u043c\u044f constraint-\u0430 \u0432 PostgreSQL \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <code>pg_constraint.conname<\/code> \u043f\u0440\u044f\u043c\u043e \u043f\u043e\u043c\u0435\u0447\u0435\u043d \u043a\u0430\u043a \u00abnot necessarily unique\u00bb, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 \u0438\u043d\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0442\u043e\u0440\u0430 \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u0442\u044c <code>Name<\/code> \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u043c ID. \u041d\u0430\u0434\u0451\u0436\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u043a\u0443 <code>schema + table + name + kind<\/code>, \u0430 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u043c\u0438 \u2014 <code>oid<\/code>.<\/p>\n<hr\/>\n<h3>\u0418\u043d\u0434\u0435\u043a\u0441\u044b: \u043f\u0435\u0440\u0432\u0430\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u043b\u043e\u0432\u0443\u0448\u043a\u0430<\/h3>\n<p>\u041d\u0430\u0438\u0432\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>&#171;`<\/p>\n<pre><code class=\"go\">type Index struct {\u00a0 \u00a0 Name \u00a0 \u00a0string\u00a0 \u00a0 Table \u00a0 string\u00a0 \u00a0 Columns []string\u00a0 \u00a0 Unique \u00a0bool}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418 \u043e\u043d\u0430 \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0447\u0442\u0438 \u0441\u0440\u0430\u0437\u0443.<\/p>\n<p>\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 PostgreSQL \u0438\u043d\u0434\u0435\u043a\u0441 \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043b\u044e\u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u0438\u00bb.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0440\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<pre><code class=\"sql\">CREATE INDEX users_email_lower_idx    -- \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043b\u043e\u043d\u043a\u0443\u00a0 \u00a0 ON users (lower(email));CREATE INDEX users_active_email_idx\u00a0 \u00a0 ON users (email)    -- \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043f\u0430\u043b\u0438 \u043f\u043e\u0434 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u00a0 \u00a0 WHERE deleted_at IS NULL;CREATE INDEX users_data_gin_idx    -- \u044f\u0432\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0438\u043f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 USING\u00a0 \u00a0 ON users USING gin (data);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u043b\u0443\u0447\u0448\u0435 \u0441\u0440\u0430\u0437\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"go\">type Index struct {\u00a0 \u00a0 Schema \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 TableSchema string\u00a0 \u00a0 TableName \u00a0 string\u00a0 \u00a0 Name \u00a0 string\u00a0 \u00a0 Unique bool\u00a0 \u00a0 Method string\u00a0 \u00a0 Keys []IndexKey\u00a0 \u00a0 Include []string\u00a0 \u00a0 Predicate string}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u043a\u043b\u044e\u0447 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"go\">type IndexKey struct {\u00a0 \u00a0 Expression string}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442:<\/p>\n<pre><code class=\"go\">IndexKey{Expression: \"email\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"go\">IndexKey{Expression: \"lower(email)\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043f\u043e \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c, \u0430 expression\/partial indexes \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 SQL. \u041c\u044b \u043d\u0435 \u0442\u0435\u0440\u044f\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043d\u043e \u0438 \u043d\u0435 \u043e\u0431\u0435\u0449\u0430\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 AST \u0432\u0441\u0435\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 PostgreSQL.<\/p>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432:<\/p>\n<pre><code class=\"sql\">SELECT    -- \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u00a0 \u00a0 table_ns.nspname AS table_schema,     -- \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u00a0 \u00a0 table_cls.relname AS table_name,    -- \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u00a0 \u00a0 index_ns.nspname AS index_schema,    -- \u0438\u043c\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u00a0 \u00a0 index_cls.relname AS index_name,     -- true, \u0435\u0441\u043b\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f UNIQUE\u00a0 \u00a0 idx.indisunique,     -- true, \u0435\u0441\u043b\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f PRIMARY KEY\u00a0 \u00a0 idx.indisprimary,     -- true, \u0435\u0441\u043b\u0438 \u0432 UNIQUE-\u0438\u043d\u0434\u0435\u043a\u0441\u0435 NULL \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u043c\u0441\u044f \u043e\u0442 NULL\u00a0 \u00a0 idx.indnullsnotdistinct,    -- \u043c\u0435\u0442\u043e\u0434 \u0438\u043d\u0434\u0435\u043a\u0441\u0430: btree, hash, gin, gist, brin \u0438 \u0442.\u0434.\u00a0 \u00a0 am.amname AS method,    -- \u043f\u043e\u043b\u043d\u043e\u0435 SQL-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u00a0 \u00a0 PG_GET_INDEXDEF(index_cls.oid, 0, FALSE) AS index_def,     -- \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0435\u0441\u043b\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 partial\u00a0 \u00a0 PG_GET_EXPR(idx.indpred, idx.indrelid, FALSE) AS predicate -- \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 PostgreSQL \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e\u0431 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445FROM pg_index idx-- \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043c\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0430JOIN pg_class index_cls ON index_cls.oid = idx.indexrelid-- \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u0441\u043e \u0441\u0445\u0435\u043c\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430JOIN pg_namespace index_ns ON index_ns.oid = index_cls.relnamespace-- \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u043dJOIN pg_class table_cls ON table_cls.oid = idx.indrelid-- \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u043e \u0441\u0445\u0435\u043c\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044bJOIN pg_namespace table_ns ON table_ns.oid = table_cls.relnamespace-- \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430: btree, hash, gin, gist, brin \u0438 \u0442.\u0434.JOIN pg_am am ON am.oid = index_cls.relam-- \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0441\u0445\u0435\u043c\u044b PostgreSQLWHERE table_ns.nspname NOT IN ('pg_catalog', 'information_schema')ORDER BY table_ns.nspname, table_cls.relname, index_cls.relname;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>pg_index<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0444\u043b\u0430\u0433\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, primary key, validity, \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043b\u044e\u0447\u0435\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, expression-\u0447\u0430\u0441\u0442\u0438 \u0438 predicate \u0434\u043b\u044f partial index. \u0415\u0441\u043b\u0438 \u0432 <code>indkey<\/code> \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f <code>0<\/code>, \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u043a\u0443. <code>indpred<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 predicate partial index-\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0433\u043e SQL PostgreSQL \u0434\u0430\u0451\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>pg_get_expr<\/code>, <code>pg_get_constraintdef<\/code> \u0438 <code>pg_get_indexdef<\/code>. \u0412\u0430\u0436\u043d\u0430\u044f \u043e\u0433\u043e\u0432\u043e\u0440\u043a\u0430 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: \u044d\u0442\u043e decompiled reconstruction, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0430 \u043d\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043a\u043e\u0433\u0434\u0430-\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a.<\/p>\n<p>\u042d\u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0435 \u043d\u0430\u0434\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u00ab\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442\u00bb. \u0415\u0433\u043e \u0443\u0436\u0435 \u043d\u0435\u0442. \u0415\u0441\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0430\u0437\u044b.<\/p>\n<hr\/>\n<h3>\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f: \u0447\u0442\u043e\u0431\u044b diff \u043d\u0435 \u0441\u0445\u043e\u0434\u0438\u043b \u0441 \u0443\u043c\u0430<\/h3>\n<p>\u0421\u0430\u043c\u0430\u044f \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c introspection \u2014 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0434\u0430\u0451\u0442 \u043e\u0434\u0438\u043d JSON, \u0430 \u0437\u0430\u0432\u0442\u0440\u0430 \u0434\u0440\u0443\u0433\u043e\u0439, diff \u0431\u0443\u0434\u0435\u0442 \u0448\u0443\u043c\u0435\u0442\u044c. \u0410 \u0435\u0441\u043b\u0438 diff \u0448\u0443\u043c\u0438\u0442, \u0430\u0432\u0442\u043e\u043c\u0438\u0433\u0440\u0430\u0442\u043e\u0440\u0443 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c.<\/p>\n<p>Snapshot \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c:<\/p>\n<blockquote>\n<p>\u041e\u0434\u043d\u043e\u0438 \u0442\u043e \u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u043b\u0436\u043d\u043e \u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 Go-\u043e\u0431\u044a\u0435\u043a\u0442, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<\/blockquote>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<pre><code class=\"go\">func (s *Schema) normalize() {\u00a0 \u00a0 sort.SliceStable(s.Tables, func(i, j int) bool {\u00a0 \u00a0 \u00a0 \u00a0 if s.Tables[i].Schema == s.Tables[j].Schema {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return s.Tables[i].Name &lt; s.Tables[j].Name\u00a0 \u00a0 \u00a0 \u00a0 }\u00a0 \u00a0 \u00a0 \u00a0 return s.Tables[i].Schema &lt; s.Tables[j].Schema\u00a0 \u00a0 })\u00a0 \u00a0 for i := range s.Tables {\u00a0 \u00a0 \u00a0 \u00a0 s.Tables[i].normalize()\u00a0 \u00a0 }}func (t *Table) normalize() {\u00a0 \u00a0 sort.SliceStable(t.Columns, func(i, j int) bool {\u00a0 \u00a0 \u00a0 \u00a0 return t.Columns[i].Position &lt; t.Columns[j].Position\u00a0 \u00a0 })\u00a0 \u00a0 sort.SliceStable(t.Constraints, func(i, j int) bool {\u00a0 \u00a0 \u00a0 \u00a0 left := constraintKindOrder(t.Constraints[i].Kind)\u00a0 \u00a0 \u00a0 \u00a0 right := constraintKindOrder(t.Constraints[j].Kind)\u00a0 \u00a0 \u00a0 \u00a0 if left == right {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return t.Constraints[i].Name &lt; t.Constraints[j].Name\u00a0 \u00a0 \u00a0 \u00a0 }\u00a0 \u00a0 \u00a0 \u00a0 return left &lt; right\u00a0 \u00a0 })\u00a0 \u00a0 sort.SliceStable(t.Indexes, func(i, j int) bool {\u00a0 \u00a0 \u00a0 \u00a0 return t.Indexes[i].Name &lt; t.Indexes[j].Name\u00a0 \u00a0 })}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418 \u043f\u043e\u0440\u044f\u0434\u043e\u043a constraints:<\/p>\n<pre><code class=\"go\">func constraintKindOrder(kind ConstraintKind) int {\u00a0 \u00a0 switch kind {\u00a0 \u00a0 case ConstraintPrimaryKey:\u00a0 \u00a0 \u00a0 \u00a0 return 1\u00a0 \u00a0 case ConstraintUnique:\u00a0 \u00a0 \u00a0 \u00a0 return 2\u00a0 \u00a0 case ConstraintCheck:\u00a0 \u00a0 \u00a0 \u00a0 return 3\u00a0 \u00a0 case ConstraintForeignKey:\u00a0 \u00a0 \u00a0 \u00a0 return 4\u00a0 \u00a0 default:\u00a0 \u00a0 \u00a0 \u00a0 return 100\u00a0 \u00a0 }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0445\u043e\u0436\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u0432 <code>qrafter<\/code>: snapshot \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u043e \u0441\u0445\u0435\u043c\u0435 \u0438 \u0438\u043c\u0435\u043d\u0438, \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u043f\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u0438, constraints \u043f\u043e \u0442\u0438\u043f\u0443 \u0438 \u0438\u043c\u0435\u043d\u0438, \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043f\u043e \u0438\u043c\u0435\u043d\u0438.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438, \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0435\u0434\u0438\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e <code>int8<\/code> \u0438 <code>bigint<\/code> \u2014 \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u044b, \u043d\u043e \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0438\u043f;<\/p>\n<\/li>\n<li>\n<p>\u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c default expressions;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0432\u0430\u0436\u043d\u044b\u043c\u0438 \u0442\u0430\u043c, \u0433\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u0445 \u043d\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u043b;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0434\u0435\u043b\u044f\u0442\u044c constraint indexes \u043e\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 indexes.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0435\u0444\u043e\u043b\u0442\u044b\u043d\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0432\u0430\u0440\u043d\u044b.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">now()<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0438<\/p>\n<pre><code class=\"sql\">CURRENT_TIMESTAMP<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c\u0438 \u0434\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043b\u0443\u0447\u0448\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c expression \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u043c\u043d\u044b\u0439 diff. \u0423\u043c\u043d\u044b\u0439 diff \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430.<\/p>\n<hr\/>\n<p><strong>## \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/strong><\/p>\n<p>\u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<p>&#171;`<\/p>\n<pre><code class=\"sql\">CREATE TABLE users (\u00a0 \u00a0 id BIGSERIAL PRIMARY KEY,\u00a0 \u00a0 email VARCHAR(320) NOT NULL UNIQUE,\u00a0 \u00a0 name TEXT,\u00a0 \u00a0 created_at TIMESTAMPTZ NOT NULL DEFAULT now());<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 introspection snapshot \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"go\">Schema{\u00a0 \u00a0 Tables: []Table{\u00a0 \u00a0 \u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Schema: \"public\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Name: \u00a0 \"users\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Columns: []Column{\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Schema: \u00a0 \u00a0 \u00a0 \"public\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 TableName: \u00a0 \u00a0\"users\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Position: \u00a0 \u00a0 1,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Name: \u00a0 \u00a0 \u00a0 \u00a0 \"id\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 DatabaseType: \"bigint\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 NotNull: \u00a0 \u00a0 \u00a0true,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 HasDefault: \u00a0 true,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 DefaultExpr: \u00a0\"nextval('users_id_seq'::regclass)\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Schema: \u00a0 \u00a0 \u00a0 \"public\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 TableName: \u00a0 \u00a0\"users\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Position: \u00a0 \u00a0 2,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Name: \u00a0 \u00a0 \u00a0 \u00a0 \"email\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 DatabaseType: \"character varying(320)\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 NotNull: \u00a0 \u00a0 \u00a0true,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Schema: \u00a0 \u00a0 \u00a0 \"public\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 TableName: \u00a0 \u00a0\"users\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Position: \u00a0 \u00a0 3,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Name: \u00a0 \u00a0 \u00a0 \u00a0 \"name\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 DatabaseType: \"text\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 NotNull: \u00a0 \u00a0 \u00a0false,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Schema: \u00a0 \u00a0 \u00a0 \"public\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 TableName: \u00a0 \u00a0\"users\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Position: \u00a0 \u00a0 4,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Name: \u00a0 \u00a0 \u00a0 \u00a0 \"created_at\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 DatabaseType: \"timestamp with time zone\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 NotNull: \u00a0 \u00a0 \u00a0true,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 HasDefault: \u00a0 true,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 DefaultExpr: \u00a0\"now()\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Constraints: []Constraint{\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Schema: \u00a0 \u00a0\"public\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 TableName: \"users\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Name: \u00a0 \u00a0 \u00a0\"users_pkey\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Kind: \u00a0 \u00a0 \u00a0ConstraintPrimaryKey,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Columns: \u00a0 []string{\"id\"},\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Schema: \u00a0 \u00a0\"public\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 TableName: \"users\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Name: \u00a0 \u00a0 \u00a0\"users_email_key\",\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Kind: \u00a0 \u00a0 \u00a0ConstraintUnique,\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Columns: \u00a0 []string{\"email\"},\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },\u00a0 \u00a0 \u00a0 \u00a0 },\u00a0 \u00a0 },}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <code>id<\/code>.<\/p>\n<p>\u041c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 <code>bigserial<\/code>, \u043d\u043e \u0432 snapshot \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 <code>bigint<\/code> \u0438 <code>nextval(...)<\/code>. \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e: PostgreSQL \u0441\u0430\u043c \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 <code>bigserial<\/code> \u0432 bigint-\u043a\u043e\u043b\u043e\u043d\u043a\u0443, sequence \u0438 default expression.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c snapshot-\u0442\u0435\u0441\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c dev\/stage\/prod \u0441\u0445\u0435\u043c\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c diff \u0432 \u043f\u0430\u043c\u044f\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0432 DDL-\u0431\u0438\u043b\u0434\u0435\u0440;<\/p>\n<\/li>\n<li>\n<p>\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b \u0432 CI.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u0427\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0437\u0430 \u043a\u0430\u0434\u0440\u043e\u043c<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043c\u044b \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u043b\u0438 \u043c\u043d\u043e\u0433\u043e \u0432\u0430\u0436\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, views \u0438 materialized views. \u0412 <code>pg_class<\/code> \u043e\u043d\u0438 \u0442\u043e\u0436\u0435 \u0435\u0441\u0442\u044c, \u043d\u043e \u0434\u043b\u044f \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c: \u0442\u0435\u043b\u043e view, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f. <code>pg_class.relkind<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b, sequences, views, materialized views \u0438 partitioned tables.<\/p>\n<p>\u041d\u0435 \u0442\u0440\u043e\u0433\u0430\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u044b. \u0414\u043b\u044f \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0440\u043e\u0434\u0435 <code>pg_get_functiondef<\/code> \/ <code>pg_get_triggerdef<\/code>, \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043b\u0430\u0441\u0442 PostgreSQL.<\/p>\n<p>\u041d\u0435 \u0442\u0440\u043e\u0433\u0430\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 enum\/domain types. <code>information_schema.columns<\/code> \u0434\u0430\u0441\u0442 \u0447\u0430\u0441\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0442\u0438\u043f\u0430\u0445, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0442\u0438\u043f\u044b \u0432 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u0445, \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 schema objects. <code>pg_type<\/code> \u043a\u0430\u043a \u0440\u0430\u0437 \u0445\u0440\u0430\u043d\u0438\u0442 base types, enum types, domains \u0438 composite types.<\/p>\n<p>\u041d\u0435 \u0442\u0440\u043e\u0433\u0430\u043b\u0438 partitions, RLS, comments, extensions, grants.<\/p>\n<hr\/>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c ALTER TABLE<\/h3>\n<p>\u041e\u0447\u0435\u043d\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 introspection \u0441\u0440\u0430\u0437\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c:<\/p>\n<pre><code class=\"go\">schema.DDL().Render(dialect.PostgreSQL{})<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e. \u041d\u043e \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0440\u0430\u043d\u043e, \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u043c \u043d\u0430 demo \u0438 \u043e\u043f\u0430\u0441\u043d\u044b\u043c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0434\u043b\u0438\u043d\u043d\u0435\u0435:<\/p>\n<ol>\n<li>\n<p>\u0421\u043d\u044f\u0442\u044c snapshot \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0445\u0435\u043c\u044b.<\/p>\n<\/li>\n<li>\n<p>\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c snapshot.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043d\u044f\u0442\u044c \u0438\u043b\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 snapshot.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0434\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c diff \u0432 DDL.<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c SQL.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0441 SQL-\u0440\u0435\u043d\u0434\u0435\u0440\u0430, \u0430 \u0441 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043b\u043e\u0436\u0438\u0442\u0441\u044f \u043d\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0441 DDL-\u0431\u0438\u043b\u0434\u0435\u0440\u043e\u043c. \u0412 <code>qrafter<\/code> DDL \u0443\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 statement-\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438: \u043c\u043e\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c <code>CreateTable<\/code>, <code>Unique<\/code>, <code>ForeignKey<\/code>, <code>CreateIndex<\/code>, \u0430 \u043f\u043e\u0442\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u043e \u043f\u043e\u0434 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 dialect.<\/p>\n<p>Snapshot \u2014 \u044d\u0442\u043e \u043c\u043e\u0441\u0442 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0438 \u0442\u0430\u043a\u0438\u043c DDL API.<\/p>\n<p>\u041f\u043e\u043a\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 snapshot.<\/p>\n<p>\u0410 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 diff \u0431\u0435\u0437 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e snapshot-\u0430 \u043d\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c.<\/p>\n<blockquote>\n<p>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 qrafter \u0432 GitHub: <a href=\"https:\/\/github.com\/SennovE\/qrafter\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/SennovE\/qrafter<\/a><\/p>\n<\/blockquote>\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\/articles\/1045496\/\">https:\/\/habr.com\/ru\/articles\/1045496\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u00ab\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439\u00bb, \u043e\u0431\u044b\u0447\u043d\u043e \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:CREATE TABLE users (\u00a0 \u00a0 id BIGSERIAL PRIMARY KEY,\u00a0 \u00a0 email TEXT NOT NULL);\u041d\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0441 CREATE TABLE. \u041e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043c\u0435\u043d\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u043d\u043e\u0433\u043e, \u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430:\u041a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0431\u0430\u0437\u044b \u0432 \u043a\u043e\u0434\u0435?\u041f\u043e\u043a\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0447\u0442\u0438 \u043d\u0438\u0447\u0435\u0433\u043e:\u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0431\u0430\u0437\u044b;\u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439;\u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c diff \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438;\u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 ALTER TABLE, CREATE INDEX \u0438 DROP CONSTRAINT \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c.\u0412 \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u044f \u0431\u0443\u0434\u0443 \u0438\u0434\u0442\u0438 \u043a \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043d\u0430 Go \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 Go. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 PostgreSQL \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0435\u0433\u043e \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e Go-\u043c\u043e\u0434\u0435\u043b\u044c.\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0443\u044e:type Schema struct {\u00a0 \u00a0 Tables []Table}type Table struct {\u00a0 \u00a0 Schema \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 Name \u00a0 \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 Columns \u00a0 \u00a0 []Column\u00a0 \u00a0 Constraints []Constraint\u00a0 \u00a0 Indexes \u00a0 \u00a0 []Index}\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u0447\u0430\u0441\u0442\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 qrafter: \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0443\u0436\u0435 \u0443\u043c\u0435\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 DDL-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0430 \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b Schema, Table, Column, Constraint, Index, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 ddl.Statements.\u0417\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u0438\u0437 \u0431\u0430\u0437\u044b\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0436\u0438\u0432\u0451\u0442 \u0443\u0436\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442.\u0412 \u0431\u0430\u0437\u0435 \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0438, \u043a\u0430\u043a\u0438\u0435-\u0442\u043e default now(), \u043f\u0430\u0440\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0442\u043e-\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443 \u0432\u0435\u0447\u0435\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u0434 \u0440\u0435\u043b\u0438\u0437\u043e\u043c.\u0418 \u0432\u043e\u0442 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c: \u0412\u043e\u0442 \u0447\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0431\u0430\u0437\u0435.\u0412\u043e\u0442 \u0447\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.\u0412\u043e\u0442 \u0447\u0435\u043c \u043e\u043d\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f.\u0412\u043e\u0442 \u0442\u0430\u043a \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0445\u0435\u043c\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u043e\u0435\u043a\u0442 \u0440\u0430\u0441\u0442\u0435\u0442 \u0438 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.\u041d\u0430\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: \u0432\u0437\u044f\u0442\u044c pg_dump &#8212;schema-only, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c SQL \u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0438\u0442\u044c.\u0417\u0432\u0443\u0447\u0438\u0442 \u0437\u0430\u043c\u0430\u043d\u0447\u0438\u0432\u043e. \u041d\u043e \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0431\u043e\u043b\u043e\u0442\u043e.\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e SQL-\u0442\u0435\u043a\u0441\u0442 \u2014 \u044d\u0442\u043e \u043d\u0435 \u043c\u043e\u0434\u0435\u043b\u044c. \u042d\u0442\u043e \u0443\u0436\u0435 \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u0414\u0432\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 SQL \u043c\u043e\u0433\u0443\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0441\u0445\u0435\u043c\u0443:CREATE UNIQUE INDEX users_email_idx ON users USING btree (email);CREATE UNIQUE INDEX users_email_idx ON public.users (email);\u0414\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435. \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e diff-\u0430 \u2014 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b.\u0410 \u0435\u0449\u0451 pg_dump \u0445\u043e\u0440\u043e\u0448 \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u044b, \u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d \u0431\u044b\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u043c AST \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0438\u0433\u0440\u0430\u0442\u043e\u0440\u0430. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043d\u044f SQL, \u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:Table{\u00a0 \u00a0 Schema: &#171;public&#187;,\u00a0 \u00a0 Name: \u00a0 &#171;users&#187;,\u00a0 \u00a0 Columns: []Column{\u00a0 \u00a0 \u00a0 \u00a0 {Name: &#171;id&#187;, DatabaseType: &#171;bigint&#187;, NotNull: true, &#8230;},\u00a0 \u00a0 \u00a0 \u00a0 {Name: &#171;email&#187;, DatabaseType: &#171;character varying(320)&#187;, NotNull: true, &#8230;},\u00a0 \u00a0 },\u00a0 \u00a0 Constraints: []Constraint{\u00a0 \u00a0 \u00a0 \u00a0 {Kind: ConstraintPrimaryKey, Columns: []string{&#171;id&#187;}, &#8230;},\u00a0 \u00a0 \u00a0 \u00a0 {Kind: ConstraintUnique, Columns: []string{&#171;email&#187;}, &#8230;},\u00a0 \u00a0 },}\u0418\u0437 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c: \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0432 DDL.\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u043e\u0439PostgreSQL \u0431\u043e\u043b\u044c\u0448\u043e\u0439. \u041e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439.\u0415\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0451, \u0441\u0442\u0430\u0442\u044c\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 pg_depend, pg_rewrite, RLS policies \u0438 \u0442\u0438\u0445\u043e\u0433\u043e \u043e\u0442\u0447\u0430\u044f\u043d\u0438\u044f.\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e.\u0411\u0443\u0434\u0435\u043c \u0447\u0438\u0442\u0430\u0442\u044c:\u0441\u0445\u0435\u043c\u044b PostgreSQL;\u0442\u0430\u0431\u043b\u0438\u0446\u044b;\u043a\u043e\u043b\u043e\u043d\u043a\u0438;\u0442\u0438\u043f\u044b \u043a\u043e\u043b\u043e\u043d\u043e\u043a;NOT NULL;default expressions;primary key;unique constraints;foreign keys;indexes.\u041f\u043e\u043a\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0437\u0430 \u043a\u0430\u0434\u0440\u043e\u043c:views;materialized views;triggers;functions;enum\/domain types \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b;partitions;policies\/RLS;comments;extensions;privileges;sequences \u043a\u0430\u043a \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438;exclusion constraints;storage options;tablespaces, \u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.\u042d\u0442\u043e \u043d\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0435 \u0432\u0430\u0436\u043d\u044b. \u041d\u0430\u043e\u0431\u043e\u0440\u043e\u0442: \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f PostgreSQL, \u0440\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u0442\u0443\u0434\u0430 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u0438\u0439\u0442\u0438. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0430\u0432\u0442\u043e\u043c\u0438\u0433\u0440\u0430\u0442\u043e\u0440\u0430 \u2014 \u043d\u0435 \u0441\u0442\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u044b\u043c pg_dump, \u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439, \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 snapshot.\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e information_schema?\u0412 PostgreSQL \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445:information_schema;pg_catalog.information_schema \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043b\u043e\u0439. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 PostgreSQL \u043f\u0440\u044f\u043c\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e information schema \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 SQL-\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u043e\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u0430 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430, \u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 PostgreSQL \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u0430\u043c \u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u043e\u0435 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u0435: PostgreSQL-\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 information schema \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0434\u043b\u044f \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438.\u0417\u0432\u0443\u0447\u0438\u0442 \u0442\u0430\u043a, \u0431\u0443\u0434\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c information_schema.\u041d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a:information_schema \u2014 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u044fpg_catalog \u2014 \u043d\u0443\u0436\u0435\u043d \u0442\u0430\u043c, \u0433\u0434\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 PostgreSQL\u0414\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a information_schema \u043f\u0440\u0438\u044f\u0442\u043d\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, information_schema.columns \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b, \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043f\u043e\u0437\u0438\u0446\u0438\u044e, default expression, nullability, \u0442\u0438\u043f, identity\/generated-\u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u0438\u043f\u0430\u0445.\u041d\u043e \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043f\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c, \u0442\u043e\u0447\u043d\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0438\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 PostgreSQL-\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u2014 \u0438\u0434\u0451\u043c \u0432 pg_catalog.\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0445\u0435\u043c\u044b \u0432 Go\u041f\u0435\u0440\u0435\u0434 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043a\u0443\u0447\u043d\u0443\u044e, \u043d\u043e \u0432\u0430\u0436\u043d\u0443\u044e \u0432\u0435\u0449\u044c: \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c.\u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0438\u043d\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0442\u043e\u0440 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432 \u043d\u0430\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 loadSomething, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 DTO, \u0430 \u043f\u043e\u0442\u043e\u043c \u0433\u0434\u0435-\u0442\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u0441\u0451 \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0447\u0435\u0441\u0442\u043d\u043e\u043c \u0441\u043b\u043e\u0432\u0435.\u0414\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0442\u0430\u043a:type Schema struct {\u00a0 \u00a0 Tables []Table}type Table struct {\u00a0 \u00a0 Schema \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 Name \u00a0 \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 Columns \u00a0 \u00a0 []Column\u00a0 \u00a0 Constraints []Constraint\u00a0 \u00a0 Indexes \u00a0 \u00a0 []Index}\u041a\u043e\u043b\u043e\u043d\u043a\u0430:type Column struct {\u00a0 \u00a0 Schema \u00a0 \u00a0    string\u00a0 \u00a0 TableName     string\u00a0 \u00a0 Position \u00a0    int\u00a0 \u00a0 Name \u00a0 \u00a0 \u00a0 \u00a0  string\u00a0 \u00a0 DatabaseType  string\u00a0 \u00a0 NotNull       bool\u00a0 \u00a0 HasDefault    bool\u00a0 \u00a0 DefaultExpr   string\u00a0 \u00a0 Identity \u00a0 \u00a0 \u00a0IdentityKind\u00a0 \u00a0 Generated \u00a0 \u00a0 GeneratedKind\u00a0 \u00a0 GeneratedExpr string}Constraint:type ConstraintKind stringconst (\u00a0 \u00a0 ConstraintPrimaryKey ConstraintKind = &#171;primary_key&#187;\u00a0 \u00a0 ConstraintUnique \u00a0 \u00a0 ConstraintKind = &#171;unique&#187;\u00a0 \u00a0 ConstraintCheck \u00a0 \u00a0 \u00a0ConstraintKind = &#171;check&#187;\u00a0 \u00a0 ConstraintForeignKey ConstraintKind = &#171;foreign_key&#187;)type Reference struct {\u00a0 \u00a0 Schema \u00a0 \u00a0string\u00a0 \u00a0 TableName string\u00a0 \u00a0 Columns \u00a0 []string}type Constraint struct {\u00a0 \u00a0 Schema \u00a0 \u00a0string\u00a0 \u00a0 TableName string\u00a0 \u00a0 Name      string\u00a0 \u00a0 Kind      ConstraintKind\u00a0 \u00a0 Columns   []string\u00a0 \u00a0 CheckExpr string\u00a0 \u00a0 Reference Reference\u00a0 \u00a0 OnDelete \u00a0string\u00a0 \u00a0 OnUpdate \u00a0string}\u0418\u043d\u0434\u0435\u043a\u0441:type IndexKey struct {\u00a0 \u00a0 \/\/ \u0414\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438:\u00a0 \u00a0 \/\/ &#171;email&#187;\u00a0 \u00a0 \/\/\u00a0 \u00a0 \/\/ \u0414\u043b\u044f expression index:\u00a0 \u00a0 \/\/ &#171;lower(email)&#187;\u00a0 \u00a0 Expression string}type Index struct {\u00a0 \u00a0 Schema \u00a0 \u00a0 \u00a0string\u00a0 \u00a0 TableSchema string\u00a0 \u00a0 TableName \u00a0 string\u00a0 \u00a0 Name \u00a0      string\u00a0 \u00a0 Unique      bool\u00a0 \u00a0 Method      string\u00a0 \u00a0 Keys        []IndexKey\u00a0 \u00a0 Include     []string\u00a0 \u00a0 Predicate   string \/\/ partial index: where &#8230;}\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 qrafter \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0445\u043e\u0436\u0430\u044f, \u043d\u043e \u0443\u0436\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 ddl-\u043f\u0430\u043a\u0435\u0442\u043e\u043c: Column \u0445\u0440\u0430\u043d\u0438\u0442 ddl.Type, Constraint \u0443\u043c\u0435\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 ddl.TableConstraint, \u0430 Index \u2014 \u0432 ddl.CreateIndexStmt. \u0423 Schema.DDL() \u0435\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f CREATE TABLE, \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e CREATE TABLE.\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043c\u044b\u0441\u043b\u044c: \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0431\u0449\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u0432 PostgreSQL \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430, \u043d\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 PostgreSQL.\u041f\u043b\u043e\u0445\u0430\u044f \u0438\u0434\u0435\u044f:type Column struct {\u00a0 \u00a0 Name string\u00a0 \u00a0 Type string}\u041b\u0443\u0447\u0448\u0435:type Column struct {\u00a0 \u00a0 Name string\u00a0 \u00a0 \/\/ \u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 DDL.\u00a0 \u00a0 Type ddl.Type\u00a0 \u00a0 \/\/ \u0422\u043e, \u0447\u0442\u043e \u0432\u0435\u0440\u043d\u0443\u043b\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f \u0431\u0430\u0437\u0430.\u00a0 \u00a0 DatabaseType string\u00a0 \u00a0 \/\/ PostgreSQL-specific \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.\u00a0 \u00a0 Raw map[string]string}\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0421\u0423\u0411\u0414 \u043e\u0431\u044b\u0447\u043d\u043e \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043d\u0430 CREATE TABLE users, \u0430 \u043d\u0430 \u043c\u0435\u043b\u043e\u0447\u0430\u0445:serial vs identity;timestamp with time zone vs datetime;partial indexes;generated columns;ON DELETE SET NULL;NULLS NOT DISTINCT \u0443 unique indexes;\u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043a\u0430\u0432\u044b\u0447\u0435\u043a \u0438 placeholder-\u043e\u0432.\u0412 qrafter \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u044b PostgreSQL, MySQL, SQLite, Oracle \u0438 SQL Server, \u0430 DDL-\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0421\u0423\u0411\u0414. \u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b: introspection \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c PostgreSQL-first, \u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u044b.\u0427\u0438\u0442\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e: \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446.\u0427\u0435\u0440\u0435\u0437 information_schema \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:SELECT\u00a0 \u00a0 table_schema, &#8212; \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u00a0 \u00a0 table_name \u00a0 \u00a0&#8212; \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044bFROM information_schema.tables&#8212; \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\/viewWHERE table_type = &#8216;BASE TABLE&#8217;  &#8212; \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0441\u0445\u0435\u043c\u044b PostgreSQL\u00a0 AND table_schema NOT IN (&#8216;pg_catalog&#8217;, &#8216;information_schema&#8217;)ORDER BY table_schema, table_name;\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430table_schematable_namepubliccustomerspublicorder_itemssalespayments\u0415\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0439\u0442\u0438 PostgreSQL-way, \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0447\u0435\u0440\u0435\u0437 pg_class \u0438 pg_namespace:SELECT\u00a0 \u00a0 n.nspname AS table_schema, &#8212; \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u00a0 \u00a0 c.relname AS table_name, \u00a0 &#8212; \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u00a0 \u00a0 c.oid \u00a0 \u00a0 AS table_oid \u00a0 \u00a0 &#8212; \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 OID \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 PostgreSQL&#8212; \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 PostgreSQL \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438-\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u043c\u0438: \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438, view \u0438 \u0442.\u0434.FROM pg_catalog.pg_class c&#8212; \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c \u0441\u0445\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043c\u044f \u0441\u0445\u0435\u043c\u044b \u043f\u043e OIDJOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace&#8212; \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (&#8216;r&#8217;) \u0438 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (&#8216;p&#8217;)WHERE c.relkind IN (&#8216;r&#8217;, &#8216;p&#8217;)  &#8212; \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0441\u0445\u0435\u043c\u044b\u00a0 AND n.nspname NOT IN (&#8216;pg_catalog&#8217;, &#8216;information_schema&#8217;)  &#8212; \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c TOAST-\u0441\u0445\u0435\u043c\u044b PostgreSQL \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439\u00a0 AND n.nspname NOT LIKE &#8216;pg_toast%&#8217;ORDER BY n.nspname, c.relname;\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 table_schematable_nametable_oidpubliccustomers 16421salespayments 16433pg_class \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u044b: \u0438\u043d\u0434\u0435\u043a\u0441\u044b, sequences, views, materialized views, composite types \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 relation-like \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u041f\u043e\u043b\u0435 relkind \u043a\u0430\u043a \u0440\u0430\u0437 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b, sequences, views, partitioned tables \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.\u0427\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u043e\u043d\u043a\u0438\u041a\u043e\u043b\u043e\u043d\u043a\u0438 \u0442\u043e\u0436\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-482994","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/482994","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=482994"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/482994\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=482994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=482994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=482994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}