summaryrefslogtreecommitdiff
path: root/yoyo
diff options
context:
space:
mode:
authorOlly Cope <olly@ollycope.com>2020-01-28 10:17:43 +0000
committerOlly Cope <olly@ollycope.com>2020-01-28 10:17:43 +0000
commiteec522e2dc11fdaa0a7f7aebcc609d17508708ce (patch)
tree0f155cd27d2a621b93b1cadb2c2f4209f2be85ed /yoyo
parent2de25175939014f2c41d62eee5498cc6dc6362dd (diff)
downloadyoyo-eec522e2dc11fdaa0a7f7aebcc609d17508708ce.tar.gz
Code reformatting with Black
Diffstat (limited to 'yoyo')
-rw-r--r--yoyo/internalmigrations/__init__.py16
-rw-r--r--yoyo/internalmigrations/v1.py8
-rw-r--r--yoyo/internalmigrations/v2.py54
3 files changed, 44 insertions, 34 deletions
diff --git a/yoyo/internalmigrations/__init__.py b/yoyo/internalmigrations/__init__.py
index fee2c49..438ac64 100644
--- a/yoyo/internalmigrations/__init__.py
+++ b/yoyo/internalmigrations/__init__.py
@@ -53,8 +53,11 @@ def get_current_version(backend):
if version_table not in tables:
return 1
with backend.transaction():
- cursor = backend.execute("SELECT max(version) FROM {} "
- .format(backend.quote_identifier(version_table)))
+ cursor = backend.execute(
+ "SELECT max(version) FROM {} ".format(
+ backend.quote_identifier(version_table)
+ )
+ )
version = cursor.fetchone()[0]
assert version in schema_versions
return version
@@ -67,6 +70,9 @@ def mark_schema_version(backend, version):
assert version in schema_versions
if version < USE_VERSION_TABLE_FROM:
return
- backend.execute("INSERT INTO {0.version_table_quoted} VALUES (:version, :when)"
- .format(backend),
- {'version': version, 'when': datetime.utcnow()})
+ backend.execute(
+ "INSERT INTO {0.version_table_quoted} VALUES (:version, :when)".format(
+ backend
+ ),
+ {"version": version, "when": datetime.utcnow()},
+ )
diff --git a/yoyo/internalmigrations/v1.py b/yoyo/internalmigrations/v1.py
index 02ce6dc..16f9dc6 100644
--- a/yoyo/internalmigrations/v1.py
+++ b/yoyo/internalmigrations/v1.py
@@ -10,6 +10,8 @@ def upgrade(backend):
def create_migration_table(backend):
- backend.execute("CREATE TABLE {0.migration_table_quoted} ("
- "id VARCHAR(191) NOT NULL PRIMARY KEY,"
- "ctime TIMESTAMP)".format(backend))
+ backend.execute(
+ "CREATE TABLE {0.migration_table_quoted} ("
+ "id VARCHAR(191) NOT NULL PRIMARY KEY,"
+ "ctime TIMESTAMP)".format(backend)
+ )
diff --git a/yoyo/internalmigrations/v2.py b/yoyo/internalmigrations/v2.py
index 29b3eb3..5012fba 100644
--- a/yoyo/internalmigrations/v2.py
+++ b/yoyo/internalmigrations/v2.py
@@ -9,50 +9,52 @@ from yoyo.migrations import get_migration_hash
def upgrade(backend):
create_log_table(backend)
create_version_table(backend)
- cursor = backend.execute("SELECT id, ctime FROM {}"
- .format(backend.migration_table_quoted))
+ cursor = backend.execute(
+ "SELECT id, ctime FROM {}".format(backend.migration_table_quoted)
+ )
for migration_id, created_at in iter(cursor.fetchone, None):
migration_hash = get_migration_hash(migration_id)
- log_data = dict(backend.get_log_data(),
- operation='apply',
- comment=('this log entry created automatically by an '
- 'internal schema upgrade'),
- created_at_utc=created_at,
- migration_hash=migration_hash,
- migration_id=migration_id)
+ log_data = dict(
+ backend.get_log_data(),
+ operation="apply",
+ comment=(
+ "this log entry created automatically by an "
+ "internal schema upgrade"
+ ),
+ created_at_utc=created_at,
+ migration_hash=migration_hash,
+ migration_id=migration_id,
+ )
backend.execute(
"INSERT INTO {0.log_table_quoted} "
"(id, migration_hash, migration_id, operation, created_at_utc, "
"username, hostname, comment) "
"VALUES "
"(:id, :migration_hash, :migration_id, 'apply', :created_at_utc, "
- ":username, :hostname, :comment)"
- .format(backend),
- log_data)
+ ":username, :hostname, :comment)".format(backend),
+ log_data,
+ )
backend.execute("DROP TABLE {0.migration_table_quoted}".format(backend))
create_migration_table(backend)
- backend.execute("INSERT INTO {0.migration_table_quoted} "
- "SELECT migration_hash, migration_id, created_at_utc "
- "FROM {0.log_table_quoted}"
- .format(backend))
+ backend.execute(
+ "INSERT INTO {0.migration_table_quoted} "
+ "SELECT migration_hash, migration_id, created_at_utc "
+ "FROM {0.log_table_quoted}".format(backend)
+ )
def create_migration_table(backend):
backend.execute(
"CREATE TABLE {0.migration_table_quoted} ( "
-
# sha256 hash of the migration id
"migration_hash VARCHAR(64), "
-
# The migration id (ie path basename without extension)
"migration_id VARCHAR(255), "
-
# When this id was applied
"applied_at_utc TIMESTAMP, "
-
- "PRIMARY KEY (migration_hash))"
- .format(backend))
+ "PRIMARY KEY (migration_hash))".format(backend)
+ )
def create_log_table(backend):
@@ -66,13 +68,13 @@ def create_log_table(backend):
"hostname VARCHAR(255), "
"comment VARCHAR(255), "
"created_at_utc TIMESTAMP, "
- "PRIMARY KEY (id))"
- .format(backend))
+ "PRIMARY KEY (id))".format(backend)
+ )
def create_version_table(backend):
backend.execute(
"CREATE TABLE {0.version_table_quoted} ("
"version INT NOT NULL PRIMARY KEY, "
- "installed_at_utc TIMESTAMP)"
- .format(backend))
+ "installed_at_utc TIMESTAMP)".format(backend)
+ )