
from .. import utils


__all__ = ('cli_loader',)


@utils.with_cursor
def cli_command(cursor, migrations_directory='', **kwargs):
    cursor.execute("""\
        CREATE TABLE IF NOT EXISTS schema_migrations (
            version TEXT NOT NULL
        )""")
    cursor.execute("""\
        DELETE FROM schema_migrations""")
    versions = []
    for version, name in utils.get_migrations(migrations_directory):
        versions.append((version,))
    cursor.executemany("""\
        INSERT INTO schema_migrations VALUES (%s)
        """, versions)


def cli_loader(parser):
    return cli_command


from .. import utils


__all__ = ('cli_loader',)


@utils.with_cursor
def cli_command(cursor, migrations_directory='', **kwargs):
    cursor.execute("""\
        CREATE TABLE IF NOT EXISTS schema_migrations (
            version TEXT NOT NULL,
            applied TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
        )""")
    cursor.execute("""\
        DELETE FROM schema_migrations""")
    versions = []
    for version, name in utils.get_migrations(migrations_directory):
        versions.append((version,))
    cursor.executemany("""\
        INSERT INTO schema_migrations VALUES (%s)
        """, versions)


def cli_loader(parser):
    return cli_command

Add "applied" timestamp to schema migrations table
Add "applied" timestamp to schema migrations table

  
  from .. import utils
  
  
  __all__ = ('cli_loader',)
  
  
  @utils.with_cursor
  def cli_command(cursor, migrations_directory='', **kwargs):
      cursor.execute("""\
          CREATE TABLE IF NOT EXISTS schema_migrations (
-             version TEXT NOT NULL
+             version TEXT NOT NULL,
+             applied TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
          )""")
      cursor.execute("""\
          DELETE FROM schema_migrations""")
      versions = []
      for version, name in utils.get_migrations(migrations_directory):
          versions.append((version,))
      cursor.executemany("""\
          INSERT INTO schema_migrations VALUES (%s)
          """, versions)
  
  
  def cli_loader(parser):
      return cli_command
  
Add "applied" timestamp to schema migrations table
## Code Before:

from .. import utils


__all__ = ('cli_loader',)


@utils.with_cursor
def cli_command(cursor, migrations_directory='', **kwargs):
    cursor.execute("""\
        CREATE TABLE IF NOT EXISTS schema_migrations (
            version TEXT NOT NULL
        )""")
    cursor.execute("""\
        DELETE FROM schema_migrations""")
    versions = []
    for version, name in utils.get_migrations(migrations_directory):
        versions.append((version,))
    cursor.executemany("""\
        INSERT INTO schema_migrations VALUES (%s)
        """, versions)


def cli_loader(parser):
    return cli_command

## Instruction:
Add "applied" timestamp to schema migrations table
## Code After:

from .. import utils


__all__ = ('cli_loader',)


@utils.with_cursor
def cli_command(cursor, migrations_directory='', **kwargs):
    cursor.execute("""\
        CREATE TABLE IF NOT EXISTS schema_migrations (
            version TEXT NOT NULL,
            applied TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
        )""")
    cursor.execute("""\
        DELETE FROM schema_migrations""")
    versions = []
    for version, name in utils.get_migrations(migrations_directory):
        versions.append((version,))
    cursor.executemany("""\
        INSERT INTO schema_migrations VALUES (%s)
        """, versions)


def cli_loader(parser):
    return cli_command
