from tables import engine

def create_tables():
    """
    Create tables the lazy way... with raw SQL.
    """
    conn = engine.raw_connection()
    cur = conn.cursor()
    cur.execute(
"""
CREATE TABLE file_upload(
    document_name TEXT
    , time_uploaded TEXT DEFAULT now()
    , filename TEXT NOT NULL
    , word_counts JSON NOT NULL
    , PRIMARY KEY(document_name, time_uploaded)
);
"""
    )
    conn.commit()

if __name__ == '__main__':
    create_tables()

from tables import engine

def create_tables():
    """
    Create tables the lazy way... with raw SQL.
    """
    conn = engine.raw_connection()
    cur = conn.cursor()
    cur.execute(
"""
CREATE TABLE file_upload_meta(
    document_name TEXT NOT NULL
    , document_slug TEXT NOT NULL
    , time_uploaded TEXT NOT NULL DEFAULT now()
    , filename TEXT NOT NULL
    , word_counts JSON NOT NULL
    , PRIMARY KEY(document_slug, time_uploaded)
);
"""
    )
    conn.commit()

if __name__ == '__main__':
    create_tables()

Add slug field to file upload meta table, rename table
Add slug field to file upload meta table, rename table

  from tables import engine
  
  def create_tables():
      """
      Create tables the lazy way... with raw SQL.
      """
      conn = engine.raw_connection()
      cur = conn.cursor()
      cur.execute(
  """
- CREATE TABLE file_upload(
+ CREATE TABLE file_upload_meta(
-     document_name TEXT
+     document_name TEXT NOT NULL
+     , document_slug TEXT NOT NULL
-     , time_uploaded TEXT DEFAULT now()
+     , time_uploaded TEXT NOT NULL DEFAULT now()
      , filename TEXT NOT NULL
      , word_counts JSON NOT NULL
-     , PRIMARY KEY(document_name, time_uploaded)
+     , PRIMARY KEY(document_slug, time_uploaded)
  );
  """
      )
      conn.commit()
  
  if __name__ == '__main__':
      create_tables()
  
Add slug field to file upload meta table, rename table
## Code Before:
from tables import engine

def create_tables():
    """
    Create tables the lazy way... with raw SQL.
    """
    conn = engine.raw_connection()
    cur = conn.cursor()
    cur.execute(
"""
CREATE TABLE file_upload(
    document_name TEXT
    , time_uploaded TEXT DEFAULT now()
    , filename TEXT NOT NULL
    , word_counts JSON NOT NULL
    , PRIMARY KEY(document_name, time_uploaded)
);
"""
    )
    conn.commit()

if __name__ == '__main__':
    create_tables()

## Instruction:
Add slug field to file upload meta table, rename table
## Code After:
from tables import engine

def create_tables():
    """
    Create tables the lazy way... with raw SQL.
    """
    conn = engine.raw_connection()
    cur = conn.cursor()
    cur.execute(
"""
CREATE TABLE file_upload_meta(
    document_name TEXT NOT NULL
    , document_slug TEXT NOT NULL
    , time_uploaded TEXT NOT NULL DEFAULT now()
    , filename TEXT NOT NULL
    , word_counts JSON NOT NULL
    , PRIMARY KEY(document_slug, time_uploaded)
);
"""
    )
    conn.commit()

if __name__ == '__main__':
    create_tables()
