"""Models"""
# pylint: disable=invalid-name
# pylint: disable=too-few-public-methods

from sqlalchemy import Column, Integer, String, DateTime, func, MetaData
from sqlalchemy.ext.declarative import declarative_base

from todo.database import session
from todo.enums import Status


# Define convention for naming constraints
# This convention will be used by Alembic when new constraints are added
# Reference:
# http://docs.sqlalchemy.org/en/latest/core/constraints.html#configuring-constraint-naming-conventions
# http://alembic.zzzcomputing.com/en/latest/naming.html#the-importance-of-naming-constraints
convention = {
    "ix": 'ix_%(column_0_label)s',
    "uq": "uq_%(table_name)s_%(column_0_name)s",
    "ck": "ck_%(table_name)s_%(constraint_name)s",
    "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
    "pk": "pk_%(table_name)s"
}
Base = declarative_base()
Base.metadata = MetaData(naming_convention=convention)
Base.query = session.query_property()


class Task(Base):
    """Task model"""
    __tablename__ = 'tasks'

    id = Column(Integer, primary_key=True, nullable=False)
    title = Column(String, nullable=False)
    description = Column(String, nullable=False)
    status = Column(String, nullable=False)
    created_at = Column(DateTime(timezone=True),
                        server_default=func.now(),
                        nullable=False)
    updated_at = Column(DateTime(timezone=True),
                        server_default=func.now(),
                        onupdate=func.now(),
                        nullable=False)

    def __init__(self, title, description, status=Status.TO_DO.name):
        self.title = title
        self.description = description
        self.status = status

@@ -142,16 +142,28 @@
 e, func,
+ ForeignKey,
  MetaDat
@@ -219,16 +219,56 @@
 ive_base
+%0Afrom sqlalchemy.orm import relationship
 %0A%0Afrom t
@@ -309,12 +309,16 @@
 odo.
-enum
+constant
 s im
@@ -326,15 +326,13 @@
 ort 
-Status%0A
+TO_DO
 %0A%0A# 
@@ -1030,16 +1030,622 @@
 rty()%0A%0A%0A
+class Board(Base):%0A    %22%22%22Board model%22%22%22%0A    __tablename__ = 'boards'%0A%0A    id = Column(Integer, primary_key=True, nullable=False)%0A    name = Column(String, nullable=False)%0A    task_number = Column(Integer, nullable=False)%0A    created_at = Column(%0A        DateTime(timezone=True), server_default=func.now(), nullable=False)%0A    updated_at = Column(%0A        DateTime(timezone=True),%0A        server_default=func.now(),%0A        onupdate=func.now(),%0A        nullable=False)%0A    tasks = relationship('Task', backref='board')%0A%0A    def __init__(self, name):%0A        self.name = name%0A        self.task_number = 0%0A%0A%0A
 class Ta
@@ -1759,24 +1759,69 @@
 able=False)%0A
+    number = Column(Integer, nullable=False)%0A
     title = 
@@ -1960,32 +1960,41 @@
 ted_at = Column(
+%0A        
 DateTime(timezon
@@ -2005,32 +2005,8 @@
 ue),
-%0A                       
  ser
@@ -2032,32 +2032,8 @@
 w(),
-%0A                       
  nul
@@ -2069,16 +2069,25 @@
  Column(
+%0A        
 DateTime
@@ -2103,32 +2103,16 @@
 =True),%0A
-                
         
@@ -2138,32 +2138,16 @@
 .now(),%0A
-                
         
@@ -2179,38 +2179,78 @@
     
-                nullable=False
+nullable=False)%0A    board_id = Column(Integer, ForeignKey('boards.id')
 )%0A%0A 
@@ -2270,16 +2270,24 @@
 __(self,
+ number,
  title, 
@@ -2303,34 +2303,61 @@
 on, 
-status=S
+board_id, s
 tatus
-.
+=
 TO_DO
-.name):
+):%0A        self.number = number
 %0A   
@@ -2448,8 +2448,41 @@
  status%0A
+        self.board_id = board_id%0A

add Board model and add Task.board_id and Task.number columns