from migrate import *

from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from models.sector import Sector
from repository.versions import DATABASE_URL


def upgrade(migrate_engine):
    Sector.__table__.create(migrate_engine)

    engine = create_engine(DATABASE_URL, echo=False)
    session = sessionmaker(bind=engine)()
    session.add(Sector(id=1, name='Manufacturing'))
    session.add(Sector(id=19, name='Construction materials'))
    session.add(Sector(id=18, name='Electronics and Optics'))
    session.add(Sector(id=6, name='Food and Beverage'))
    session.add(Sector(id=342, name='Bakery & confectionery products'))
    session.add(Sector(id=43, name='Beverages'))
    session.add(Sector(id=42, name='Fish & fish products'))
    session.add(Sector(id=40, name='Meat & meat products'))
    session.add(Sector(id=39, name='Milk & dairy products'))
    session.add(Sector(id=437, name='Other'))
    session.add(Sector(id=378, name='Sweets & snack food'))
    session.add(Sector(id=13, name='Furniture'))
    session.add(Sector(id=389, name='Bathroom/sauna'))
    session.add(Sector(id=385, name='Bedroom'))
    session.add(Sector(id=390, name='Children’s room'))
    session.add(Sector(id=98, name='Kitchen'))
    session.add(Sector(id=101, name='Living room'))
    session.add(Sector(id=392, name='Office'))
    session.add(Sector(id=394, name='Other session.add(Sector(id=Furniture)'))
    session.add(Sector(id=341, name='Outdoor'))
    session.add(Sector(id=99, name='Project furniture'))
    session.add(Sector(id=12, name='Machinery'))
    session.add(Sector(id=94, name='Machinery components'))
    session.add(Sector(id=91, name='Machinery equipment/tools'))
    session.add(Sector(id=224, name='Manufacture of machinery'))
    session.add(Sector(id=97, name='Maritime'))
    session.add(Sector(id=271, name='Aluminium and steel workboats'))
    session.add(Sector(id=269, name='Boat/Yacht building'))
    session.add(Sector(id=230, name='Ship repair and conversion'))
    session.add(Sector(id=93, name='Metal structures'))
    session.add(Sector(id=227, name='Repair and maintenance service'))
    session.add(Sector(id=11, name='Metalworking'))
    session.add(Sector(id=67, name='Construction of metal structures'))
    session.add(Sector(id=263, name='Houses and buildings'))
    session.add(Sector(id=267, name='Metal products'))
    session.add(Sector(id=542, name='Metal works'))
    session.add(Sector(id=75, name='CNC-machining'))
    session.add(Sector(id=62, name='Forgings, Fasteners'))
    session.add(Sector(id=69, name='Gas, Plasma, Laser cutting'))
    session.add(Sector(id=66, name='MIG, TIG, Aluminum welding'))
    session.add(Sector(id=9, name='Plastic and Rubber'))
    session.add(Sector(id=54, name='Packaging'))
    session.add(Sector(id=556, name='Plastic goods'))
    session.add(Sector(id=559, name='Plastic processing technology'))
    session.add(Sector(id=55, name='Blowing'))
    session.add(Sector(id=57, name='Moulding'))
    session.add(Sector(id=53, name='Plastics welding and processing'))
    session.add(Sector(id=560, name='Plastic profiles'))
    session.add(Sector(id=5, name='Printing'))
    session.add(Sector(id=148, name='Advertising'))
    session.add(Sector(id=150, name='Book/Periodicals printing'))
    session.add(Sector(id=145, name='Labelling and packaging printing'))
    session.add(Sector(id=7, name='Textile and Clothing'))
    session.add(Sector(id=44, name='Clothing'))
    session.add(Sector(id=45, name='Textile'))
    session.add(Sector(id=8, name='Wood'))
    session.add(Sector(id=337, name='Other session.add(Sector(id=Wood)'))
    session.add(Sector(id=51, name='Wooden building materials'))
    session.add(Sector(id=47, name='Wooden houses'))
    session.add(Sector(id=37, name='Creative industries'))
    session.add(Sector(id=29, name='Energy technology'))
    session.add(Sector(id=33, name='Environment'))
    session.add(Sector(id=2, name='Service'))
    session.add(Sector(id=25, name='Business services'))
    session.add(Sector(id=35, name='Engineering'))
    session.add(Sector(id=28, name='Information Technology and Telecom'))
    session.add(Sector(id=581, name='Data processing, Web portals, E-marketing'))
    session.add(Sector(id=576, name='Programming, Consultancy'))
    session.add(Sector(id=121, name='Software, Hardware'))
    session.add(Sector(id=122, name='Telecommunications'))
    session.add(Sector(id=22, name='Tourism'))
    session.add(Sector(id=141, name='Translation services'))
    session.add(Sector(id=21, name='Transport and Logistics'))
    session.add(Sector(id=111, name='Air'))
    session.add(Sector(id=114, name='Rail'))
    session.add(Sector(id=112, name='Road'))
    session.add(Sector(id=113, name='Water'))
    session.commit()


def downgrade(migrate_engine):
    Sector.__table__.drop(migrate_engine)
