Skip to content

add SchemaEditor support for create/delete model and rename table operations #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ jobs:
ordering
or_lookups
queries
schema.tests.SchemaTests.test_creation_deletion
schema.tests.SchemaTests.test_db_table
select_related
select_related_onetoone
select_related_regress
Expand Down
20 changes: 19 additions & 1 deletion django_mongodb/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
def create_model(self, model):
pass
self.connection.database.create_collection(model._meta.db_table)

def delete_model(self, model):
self.connection.database[model._meta.db_table].drop()

def add_field(self, model, field):
pass
Expand All @@ -14,11 +17,26 @@ def alter_field(self, model, old_field, new_field, strict=False):
def remove_field(self, model, field):
pass

def alter_index_together(self, model, old_index_together, new_index_together):
pass

def alter_unique_together(self, model, old_unique_together, new_unique_together):
pass

def add_index(self, model, index):
pass

def rename_index(self, model, old_index, new_index):
pass

def remove_index(self, model, index):
pass

def add_constraint(self, model, constraint):
pass

def remove_constraint(self, model, constraint):
pass

def alter_db_table(self, model, old_db_table, new_db_table):
self.connection.database[old_db_table].rename(new_db_table)