Commit c65ecb8f authored by Eliss-good's avatar Eliss-good
Browse files

new migrate

parent 40620ec1
"""empty message
Revision ID: 71ac0e4b2c0e
Revises: c6689aa6dbb4
Create Date: 2022-06-11 18:19:22.551640
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '71ac0e4b2c0e'
down_revision = 'c6689aa6dbb4'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('coordinates_event',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('address', sa.String(), nullable=False),
sa.Column('coordinates', sa.String(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.add_column('advertisement', sa.Column('coordinates_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'advertisement', 'coordinates_event', ['coordinates_id'], ['id'])
op.drop_column('advertisement', 'coordinates')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('advertisement', sa.Column('coordinates', sa.VARCHAR(), autoincrement=False, nullable=True))
op.drop_constraint(None, 'advertisement', type_='foreignkey')
op.drop_column('advertisement', 'coordinates_id')
op.drop_table('coordinates_event')
# ### end Alembic commands ###
"""empty message
Revision ID: 738aaa18aac1
Revises: 71ac0e4b2c0e
Create Date: 2022-06-11 18:25:45.259411
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '738aaa18aac1'
down_revision = '71ac0e4b2c0e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('advertisement', sa.Column('time_event', sa.Time(), nullable=True))
op.add_column('advertisement', sa.Column('type_event', sa.String(), nullable=True))
op.add_column('advertisement', sa.Column('time_create', sa.DateTime(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('advertisement', 'time_create')
op.drop_column('advertisement', 'type_event')
op.drop_column('advertisement', 'time_event')
# ### end Alembic commands ###
......@@ -97,20 +97,34 @@ class Customers(db.Model):
self.points = points_amount
default_confirmed_status = False
class СoordinatesEvent(db.Model):
__tablename__ = 'coordinates_event'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
address = db.Column(db.String, nullable=False)
coordinates = db.Column(db.String, nullable=False)
def __int__(self, address, coordinates):
self.address = address
self.coordinates = coordinates
default_confirmed_status = False
class Advertisement(db.Model):
__tablename__ = 'advertisement'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
confirmed = db.Column(db.Integer)
adv_name = db.Column(db.String)
time_event = db.Column(db.Time)
type_event = db.Column(db.String)
time_create = db.Column(db.DateTime)
employer_id = db.Column(db.Integer, db.ForeignKey('employer.id'))
connect_employer = db.relationship('Employer', backref='advertisement_employer')
confirmed = db.Column(db.Integer)
coordinates = db.Column(db.String)
coordinates_id = db.Column(db.Integer, db.ForeignKey('coordinates_event.id'))
connect_coordinates = db.relationship('СoordinatesEvent', backref='categories_advertisement', uselist=False)
categories_id = db.Column(db.Integer, db.ForeignKey('categories.id'))
connect_categories = db.relationship('Categories', backref='categories_advertisement', uselist=False)
......
from web_setting import flask_app, cross_origin
from api.api_advertisment import login
from pydantic import BaseModel, constr
from typing import Optional
from flask import jsonify, request
@flask_app.router('/api/advertisement', methods=["POST", "GET"])
def advertisement():
from pydantic import BaseModel, constr
from typing import Optional
class AdvertisementData(BaseModel):
-
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment