Skip to content

Commit

Permalink
Rename django_migrations table to plainmigrations
Browse files Browse the repository at this point in the history
  • Loading branch information
davegaeddert committed Sep 10, 2024
1 parent b3a759c commit 72eec0f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plain-models/plain/models/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def all_items_equal(seq):
@click.option(
"--prune",
is_flag=True,
help="Delete nonexistent migrations from the django_migrations table.",
help="Delete nonexistent migrations from the plainmigrations table.",
)
@click.option(
"-v",
Expand Down
8 changes: 4 additions & 4 deletions plain-models/plain/models/migrations/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Migration(models.Model):
class Meta:
packages = Packages()
package_label = "migrations"
db_table = "django_migrations"
db_table = "plainmigrations"

def __str__(self):
return f"Migration {self.name} for {self.app}"
Expand All @@ -54,7 +54,7 @@ def migration_qs(self):
return self.Migration.objects.using(self.connection.alias)

def has_table(self):
"""Return True if the django_migrations table exists."""
"""Return True if the plainmigrations table exists."""
with self.connection.cursor() as cursor:
tables = self.connection.introspection.table_names(cursor)
return self.Migration._meta.db_table in tables
Expand All @@ -71,7 +71,7 @@ def ensure_schema(self):
editor.create_model(self.Migration)
except DatabaseError as exc:
raise MigrationSchemaMissing(
"Unable to create the django_migrations table (%s)" % exc
"Unable to create the plainmigrations table (%s)" % exc
)

def applied_migrations(self):
Expand All @@ -85,7 +85,7 @@ def applied_migrations(self):
for migration in self.migration_qs
}
else:
# If the django_migrations table doesn't exist, then no migrations
# If the plainmigrations table doesn't exist, then no migrations
# are applied.
return {}

Expand Down
2 changes: 1 addition & 1 deletion plain-models/plain/models/preflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def check_database_tables(package_configs, **kwargs):
model_tables = connection.introspection.plain_table_names()

unknown_tables = set(db_tables) - set(model_tables)
unknown_tables.discard("django_migrations") # Know this could be there
unknown_tables.discard("plainmigrations") # Know this could be there
if unknown_tables:
table_names = ", ".join(unknown_tables)
specific_hint = f'echo "DROP TABLE IF EXISTS {unknown_tables.pop()}" | plain models db-shell'
Expand Down

0 comments on commit 72eec0f

Please sign in to comment.