{"id":395665,"date":"2024-06-29T12:20:53","date_gmt":"2024-06-29T12:20:53","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=395665"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=395665","title":{"rendered":"<span>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0441 alembic \u0434\u043b\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0431\u0430\u0437\u044b<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442, \u0433\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 SQLAlchermy \u0438 Alembic. \u041d\u043e \u043f\u043e \u0432\u043e\u043b\u0435 \u0440\u043e\u043a\u0430 \u0442\u0430\u043a \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e alembic \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432 \u0431\u0430\u0437\u0435 \u043a\u0443\u0447\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0432 \u043a\u0443\u0440\u0441\u0435, SQLAlchemy &#8212; \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438 ORM \u0434\u043b\u044f \u043f\u0438\u0442\u043e\u043d\u0430, \u0430 Alembic &#8212; \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0434\u043b\u044f SQLAlchemy.<\/p>\n<p>\u041c\u044b \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u0438 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c 2 \u0432\u0435\u0449\u0438: \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0441 \u043d\u0443\u043b\u044f \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u043e\u043c. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438 \u0431\u0443\u0434\u0435\u043c \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u043e\u043c.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443, \u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439 \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u0430\u043a\u043e\u043c-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u043b\u043e\u0433\u0435. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>db.py<\/code> \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c.<\/p>\n<pre><code class=\"python\">from sqlalchemy import create_engine, Column, Integer, String, Text, ForeignKey from sqlalchemy.orm import declarative_base  engine = create_engine('postgresql:\/\/romblin@localhost\/db')  Base = declarative_base()   class User(Base):     __tablename__ = \"users\"      id = Column(Integer, primary_key=True)     username = Column(String(255), unique=True, nullable=False)     password = Column(String(255), nullable=False)     email = Column(String(255), unique=True, nullable=False)   class Comment(Base):     __tablename__ = 'comments'      id = Column(Integer, primary_key=True)     body = Column(Text, nullable=False)     user_id = Column(Integer, ForeignKey('users.id'), nullable=False)     post_id = Column(Integer, ForeignKey('posts.id'), nullable=False)   class Post(Base):     __tablename__ = 'posts'      id = Column(Integer, primary_key=True)     title = Column(String(255), nullable=True)     text = Column(Text, nullable=False)     author_id = Column(Integer, ForeignKey('users.id'), nullable=False) <\/code><\/pre>\n<p>\u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u0431\u0430\u0437\u0435.<\/p>\n<pre><code class=\"pgsql\">db=# \\dt           List of relations  Schema |   Name   | Type  |  Owner   --------+----------+-------+---------  public | comments | table | romblin  public | posts    | table | romblin  public | users    | table | romblin (3 rows)<\/code><\/pre>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0430\u043b\u0435\u043c\u0431\u0438\u043a:<\/p>\n<pre><code class=\"bash\">$ alembic init migration<\/code><\/pre>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 <code>alembic.ini<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441 \u0431\u0430\u0437\u044b:<\/p>\n<pre><code>[alembic] ... sqlalchemy.url = postgresql:\/\/romblin@localhost\/db<\/code><\/pre>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 <code>migration\/env.py<\/code> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c target_metadata:<\/p>\n<pre><code class=\"python\">from db import * target_metadata = Base.metadata<\/code><\/pre>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u043e\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0431\u0430\u0437\u0435 \u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0431\u0430\u0437\u0443 \u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0430\u043b\u0435\u0431\u043c\u0438\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0431\u0430\u0437\u044b, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u043e\u043d \u043a\u0430\u043a \u0440\u0430\u0437 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u043d\u0430\u043c \u043d\u0430\u0447\u0430\u043b\u043d\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e, \u0438 \u0443\u0436\u0435 \u043e\u0442 \u044d\u0442\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u043b\u044f\u0441\u0430\u0442\u044c, \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0431\u0430\u0437\u0443.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u0443:<\/p>\n<pre><code class=\"pgsql\">db=# CREATE DATABASE tmp; CREATE DATABASE<\/code><\/pre>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432 \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0431\u0430\u0437\u044b \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445.<\/p>\n<pre><code class=\"bash\">$ alembic revision --autogenerate -m 'initial'<\/code><\/pre>\n<p>\u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>migration\/versions\/8cb9616d5ef0_initial.py<\/code>:<\/p>\n<pre><code class=\"python\">\"\"\"initial  Revision ID: 8cb9616d5ef0 Revises: Create Date: 2021-10-24 19:27:31.205081  \"\"\" from alembic import op import sqlalchemy as sa   # revision identifiers, used by Alembic. revision = '8cb9616d5ef0' down_revision = None branch_labels = None depends_on = None   def upgrade():    # ### commands auto generated by Alembic - please adjust! ###    op.create_table('users',    sa.Column('id', sa.Integer(), nullable=False),    sa.Column('username', sa.String(length=255), nullable=False),    sa.Column('password', sa.String(length=255), nullable=False),    sa.Column('email', sa.String(length=255), nullable=False),    sa.PrimaryKeyConstraint('id'),    sa.UniqueConstraint('email'),    sa.UniqueConstraint('username')    )    op.create_table('posts',    sa.Column('id', sa.Integer(), nullable=False),    sa.Column('title', sa.String(length=255), nullable=True),    sa.Column('text', sa.Text(), nullable=False),    sa.Column('author_id', sa.Integer(), nullable=False),    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),    sa.PrimaryKeyConstraint('id')    )    op.create_table('comments',    sa.Column('id', sa.Integer(), nullable=False),    sa.Column('body', sa.Text(), nullable=False),    sa.Column('user_id', sa.Integer(), nullable=False),    sa.Column('post_id', sa.Integer(), nullable=False),    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),    sa.PrimaryKeyConstraint('id')    )    # ### end Alembic commands ###   def downgrade():    # ### commands auto generated by Alembic - please adjust! ###    op.drop_table('comments')    op.drop_table('posts')    op.drop_table('users')    # ### end Alembic commands ###<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u0432\u0443\u0430-\u043b\u044f, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c initial \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0430\u043b\u0435\u043c\u0431\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u043e\u043c \u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044f \u044d\u0442\u043e\u0442 \u043d\u0430\u0431\u043e\u0440 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0441 \u043d\u0443\u043b\u044f. \u0414\u043b\u044f \u0430\u0432\u0442\u043e\u0442\u0435\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u043e\u0432, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443.<\/p>\n<p>\u042d\u0442\u043e \u0431\u044b\u043b \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439. \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0438\u0442\u0443\u0446\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0442\u0438\u043f\u044b. \u042d\u0442\u043e \u0431\u044b\u043b \u043a\u0430\u043a \u0440\u0430\u0437 \u043d\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439, \u0438 \u0442\u0430\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0431\u0430\u0437\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c? \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0434\u0430\u043c\u043f \u0441\u0445\u0435\u043c\u044b \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0414\u0430\u043c\u043f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">$ pg_dump -h localhost -U romblin --dbname=db --no-owner --schema-only --no-privileges > migration\/schema.dump<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 \u043d\u0435\u0439 \u043d\u0430\u043c \u0434\u0430\u043c\u043f.<\/p>\n<pre><code class=\"bash\">$ alembic revision -m 'initial'<\/code><\/pre>\n<p><code>migration\/versions\/3f81b707dbe4_initial.py<\/code><\/p>\n<pre><code class=\"python\">\"\"\"init  Revision ID: 3f81b707dbe4 Revises: Create Date: 2021-10-06 12:33:17.827125  \"\"\" from pathlib import Path  from alembic import op # revision identifiers, used by Alembic. from sqlalchemy import text  revision = '3f81b707dbe4' down_revision = None branch_labels = None depends_on = None   def upgrade():    dump_path = Path(__file__).parent.parent.absolute() \/ 'schema.dump'     with open(dump_path, 'r') as sql_reader:        op.execute(text(sql_reader.read()))     op.execute(text('SET search_path = public'))   def downgrade():    # ### commands auto generated by Alembic - please adjust! ###    pass    # ### end Alembic commands ###  <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u043a \u044d\u0442\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0431\u0430\u0437\u0443. \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>stamp<\/code> \u0430\u043b\u0435\u043c\u0431\u0438\u043a\u0430. \u041d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0430\u043b\u0435\u0431\u043c\u0438\u043a\u0430 \u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"bash\">$ alembic stamp 3f81b707dbe4<\/code><\/pre>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0432 \u043d\u0443\u043b\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e alembic-\u0430.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/585228\/\"> https:\/\/habr.com\/ru\/articles\/585228\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442, \u0433\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 SQLAlchermy \u0438 Alembic. \u041d\u043e \u043f\u043e \u0432\u043e\u043b\u0435 \u0440\u043e\u043a\u0430 \u0442\u0430\u043a \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e alembic \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432 \u0431\u0430\u0437\u0435 \u043a\u0443\u0447\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0432 \u043a\u0443\u0440\u0441\u0435, SQLAlchemy &#8212; \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438 ORM \u0434\u043b\u044f \u043f\u0438\u0442\u043e\u043d\u0430, \u0430 Alembic &#8212; \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0434\u043b\u044f SQLAlchemy.<\/p>\n<p>\u041c\u044b \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u0438 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c 2 \u0432\u0435\u0449\u0438: \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0441 \u043d\u0443\u043b\u044f \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u043e\u043c. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438 \u0431\u0443\u0434\u0435\u043c \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u043e\u043c.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443, \u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439 \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u0430\u043a\u043e\u043c-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u043b\u043e\u0433\u0435. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>db.py<\/code> \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c.<\/p>\n<pre><code class=\"python\">from sqlalchemy import create_engine, Column, Integer, String, Text, ForeignKey from sqlalchemy.orm import declarative_base  engine = create_engine('postgresql:\/\/romblin@localhost\/db')  Base = declarative_base()   class User(Base):     __tablename__ = \"users\"      id = Column(Integer, primary_key=True)     username = Column(String(255), unique=True, nullable=False)     password = Column(String(255), nullable=False)     email = Column(String(255), unique=True, nullable=False)   class Comment(Base):     __tablename__ = 'comments'      id = Column(Integer, primary_key=True)     body = Column(Text, nullable=False)     user_id = Column(Integer, ForeignKey('users.id'), nullable=False)     post_id = Column(Integer, ForeignKey('posts.id'), nullable=False)   class Post(Base):     __tablename__ = 'posts'      id = Column(Integer, primary_key=True)     title = Column(String(255), nullable=True)     text = Column(Text, nullable=False)     author_id = Column(Integer, ForeignKey('users.id'), nullable=False) <\/code><\/pre>\n<p>\u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u0431\u0430\u0437\u0435.<\/p>\n<pre><code class=\"pgsql\">db=# \\dt           List of relations  Schema |   Name   | Type  |  Owner   --------+----------+-------+---------  public | comments | table | romblin  public | posts    | table | romblin  public | users    | table | romblin (3 rows)<\/code><\/pre>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0430\u043b\u0435\u043c\u0431\u0438\u043a:<\/p>\n<pre><code class=\"bash\">$ alembic init migration<\/code><\/pre>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 <code>alembic.ini<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441 \u0431\u0430\u0437\u044b:<\/p>\n<pre><code>[alembic] ... sqlalchemy.url = postgresql:\/\/romblin@localhost\/db<\/code><\/pre>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 <code>migration\/env.py<\/code> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c target_metadata:<\/p>\n<pre><code class=\"python\">from db import * target_metadata = Base.metadata<\/code><\/pre>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u043e\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0431\u0430\u0437\u0435 \u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0431\u0430\u0437\u0443 \u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0430\u043b\u0435\u0431\u043c\u0438\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0431\u0430\u0437\u044b, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u043e\u043d \u043a\u0430\u043a \u0440\u0430\u0437 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u043d\u0430\u043c \u043d\u0430\u0447\u0430\u043b\u043d\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e, \u0438 \u0443\u0436\u0435 \u043e\u0442 \u044d\u0442\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u043b\u044f\u0441\u0430\u0442\u044c, \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0431\u0430\u0437\u0443.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u0443:<\/p>\n<pre><code class=\"pgsql\">db=# CREATE DATABASE tmp; CREATE DATABASE<\/code><\/pre>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432 \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0431\u0430\u0437\u044b \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445.<\/p>\n<pre><code class=\"bash\">$ alembic revision --autogenerate -m 'initial'<\/code><\/pre>\n<p>\u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>migration\/versions\/8cb9616d5ef0_initial.py<\/code>:<\/p>\n<pre><code class=\"python\">\"\"\"initial  Revision ID: 8cb9616d5ef0 Revises: Create Date: 2021-10-24 19:27:31.205081  \"\"\" from alembic import op import sqlalchemy as sa   # revision identifiers, used by Alembic. revision = '8cb9616d5ef0' down_revision = None branch_labels = None depends_on = None   def upgrade():    # ### commands auto generated by Alembic - please adjust! ###    op.create_table('users',    sa.Column('id', sa.Integer(), nullable=False),    sa.Column('username', sa.String(length=255), nullable=False),    sa.Column('password', sa.String(length=255), nullable=False),    sa.Column('email', sa.String(length=255), nullable=False),    sa.PrimaryKeyConstraint('id'),    sa.UniqueConstraint('email'),    sa.UniqueConstraint('username')    )    op.create_table('posts',    sa.Column('id', sa.Integer(), nullable=False),    sa.Column('title', sa.String(length=255), nullable=True),    sa.Column('text', sa.Text(), nullable=False),    sa.Column('author_id', sa.Integer(), nullable=False),    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),    sa.PrimaryKeyConstraint('id')    )    op.create_table('comments',    sa.Column('id', sa.Integer(), nullable=False),    sa.Column('body', sa.Text(), nullable=False),    sa.Column('user_id', sa.Integer(), nullable=False),    sa.Column('post_id', sa.Integer(), nullable=False),    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),    sa.PrimaryKeyConstraint('id')    )    # ### end Alembic commands ###   def downgrade():    # ### commands auto generated by Alembic - please adjust! ###    op.drop_table('comments')    op.drop_table('posts')    op.drop_table('users')    # ### end Alembic commands ###<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u0432\u0443\u0430-\u043b\u044f, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c initial \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0430\u043b\u0435\u043c\u0431\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u043e\u043c \u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044f \u044d\u0442\u043e\u0442 \u043d\u0430\u0431\u043e\u0440 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0441 \u043d\u0443\u043b\u044f. \u0414\u043b\u044f \u0430\u0432\u0442\u043e\u0442\u0435\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u043e\u0432, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443.<\/p>\n<p>\u042d\u0442\u043e \u0431\u044b\u043b \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439. \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0438\u0442\u0443\u0446\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0442\u0438\u043f\u044b. \u042d\u0442\u043e \u0431\u044b\u043b \u043a\u0430\u043a \u0440\u0430\u0437 \u043d\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439, \u0438 \u0442\u0430\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0431\u0430\u0437\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c? \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0434\u0430\u043c\u043f \u0441\u0445\u0435\u043c\u044b \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0414\u0430\u043c\u043f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">$ pg_dump -h localhost -U romblin --dbname=db --no-owner --schema-only --no-privileges > migration\/schema.dump<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 \u043d\u0435\u0439 \u043d\u0430\u043c \u0434\u0430\u043c\u043f.<\/p>\n<pre><code class=\"bash\">$ alembic revision -m 'initial'<\/code><\/pre>\n<p><code>migration\/versions\/3f81b707dbe4_initial.py<\/code><\/p>\n<pre><code class=\"python\">\"\"\"init  Revision ID: 3f81b707dbe4 Revises: Create Date: 2021-10-06 12:33:17.827125  \"\"\" from pathlib import Path  from alembic import op # revision identifiers, used by Alembic. from sqlalchemy import text  revision = '3f81b707dbe4' down_revision = None branch_labels = None depends_on = None   def upgrade():    dump_path = Path(__file__).parent.parent.absolute() \/ 'schema.dump'     with open(dump_path, 'r') as sql_reader:        op.execute(text(sql_reader.read()))     op.execute(text('SET search_path = public'))   def downgrade():    # ### commands auto generated by Alembic - please adjust! ###    pass    # ### end Alembic commands ###  <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u043a \u044d\u0442\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0431\u0430\u0437\u0443. \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>stamp<\/code> \u0430\u043b\u0435\u043c\u0431\u0438\u043a\u0430. \u041d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0430\u043b\u0435\u0431\u043c\u0438\u043a\u0430 \u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"bash\">$ alembic stamp 3f81b707dbe4<\/code><\/pre>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0432 \u043d\u0443\u043b\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e alembic-\u0430.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/585228\/\"> https:\/\/habr.com\/ru\/articles\/585228\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-395665","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/395665","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=395665"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/395665\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=395665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=395665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=395665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}