from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String

Base = declarative_base()


class Label(Base):
    __tablename__ = 'labels'

    id = Column(String, primary_key=True)
    name = Column(String, unique=True)
    color = Column(String)
    description = Column(String)

    def __repr__(self):
        return "<Label(name='%s', color='%s', description='%s')>" % (
            self.name, self.color, self.description)


async def create_tables(engine):
    async with engine.begin() as conn:
        await conn.run_sync(Base.metadata.create_all)

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String, Sequence, Integer

Base = declarative_base()


class Label(Base):
    __tablename__ = 'labels'

    id = Column(Integer, Sequence('labels_id_seq'), primary_key=True)
    name = Column(String, unique=True)
    color = Column(String)
    description = Column(String)

    def __repr__(self):
        return "<Label(name='%s', color='%s', description='%s')>" % (
            self.name, self.color, self.description)


async def create_tables(engine):
    async with engine.begin() as conn:
        await conn.run_sync(Base.metadata.create_all)

Use serial integer IDs for SQL records
Use serial integer IDs for SQL records

  from sqlalchemy.ext.declarative import declarative_base
- from sqlalchemy import Column, String
+ from sqlalchemy import Column, String, Sequence, Integer
  
  Base = declarative_base()
  
  
  class Label(Base):
      __tablename__ = 'labels'
  
-     id = Column(String, primary_key=True)
+     id = Column(Integer, Sequence('labels_id_seq'), primary_key=True)
      name = Column(String, unique=True)
      color = Column(String)
      description = Column(String)
  
      def __repr__(self):
          return "<Label(name='%s', color='%s', description='%s')>" % (
              self.name, self.color, self.description)
  
  
  async def create_tables(engine):
      async with engine.begin() as conn:
          await conn.run_sync(Base.metadata.create_all)
  
Use serial integer IDs for SQL records
## Code Before:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String

Base = declarative_base()


class Label(Base):
    __tablename__ = 'labels'

    id = Column(String, primary_key=True)
    name = Column(String, unique=True)
    color = Column(String)
    description = Column(String)

    def __repr__(self):
        return "<Label(name='%s', color='%s', description='%s')>" % (
            self.name, self.color, self.description)


async def create_tables(engine):
    async with engine.begin() as conn:
        await conn.run_sync(Base.metadata.create_all)

## Instruction:
Use serial integer IDs for SQL records
## Code After:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String, Sequence, Integer

Base = declarative_base()


class Label(Base):
    __tablename__ = 'labels'

    id = Column(Integer, Sequence('labels_id_seq'), primary_key=True)
    name = Column(String, unique=True)
    color = Column(String)
    description = Column(String)

    def __repr__(self):
        return "<Label(name='%s', color='%s', description='%s')>" % (
            self.name, self.color, self.description)


async def create_tables(engine):
    async with engine.begin() as conn:
        await conn.run_sync(Base.metadata.create_all)
