-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dont relay on exisitng django migration for the command to run (#5)
- Loading branch information
Showing
11 changed files
with
59 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.db.migrations.autodetector import MigrationAutodetector | ||
from django.db.migrations.state import ProjectState | ||
from django.db.migrations.loader import MigrationLoader | ||
from django.apps import apps | ||
|
||
|
||
# Creates the migrations of the installed apps from empty baseline and returns them as a dictionary | ||
def get_migrations(): | ||
autodetector = MigrationAutodetector( | ||
ProjectState(), | ||
ProjectState.from_apps(apps), | ||
) | ||
loader = MigrationLoader(None, ignore_no_migrations=True) | ||
changes = autodetector.changes( | ||
graph=loader.graph, | ||
trim_to_apps=None, | ||
convert_apps=None, | ||
) | ||
migrations = {} | ||
for app_label, app_migrations in changes.items(): | ||
migrations[(app_label, app_migrations[0].name)] = app_migrations[0] | ||
return migrations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
INSTALLED_APPS = ["atlas_provider_django", "tests.app"] | ||
INSTALLED_APPS = ["atlas_provider_django", "tests.app1", "tests.app2"] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AppConfig(AppConfig): | ||
class App1Config(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "tests.app" | ||
name = "tests.app1" |
File renamed without changes.
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class App2Config(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "tests.app2" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.db import models | ||
|
||
|
||
class User(models.Model): | ||
first_name = models.CharField(max_length=50) | ||
last_name = models.CharField(max_length=50) | ||
roll = models.CharField(max_length=100) | ||
|
||
|
||
class Blog(models.Model): | ||
author = models.ForeignKey(User, on_delete=models.CASCADE) | ||
name = models.CharField(max_length=100) | ||
created_at = models.DateField() | ||
num_stars = models.IntegerField() |