Skip to content

Fixes #57: Add --no-db flag to make migrations optional#80

Open
Samarthegde wants to merge 1 commit into
radiac:mainfrom
Samarthegde:nanodjango-issue-57
Open

Fixes #57: Add --no-db flag to make migrations optional#80
Samarthegde wants to merge 1 commit into
radiac:mainfrom
Samarthegde:nanodjango-issue-57

Conversation

@Samarthegde

Copy link
Copy Markdown

This pull request resolves issue #57 by introducing a --no-db flag to the run command.

For prototypes and projects that don't require a database, the automatic creation of a db.sqlite3 file and the interactive createsuperuser prompt can be cumbersome. This change allows developers to quickly run a nanodjango app without any database setup or migration file creations, leading to a faster and cleaner development experience.

When the --no-db flag (or its --nodb alias) is used, the application is configured to use an in-memory SQLite database. This prevents the creation of a database file and skips the migration and superuser creation steps.

Changes Included

  • Added --no-db/--nodb flags: The run command in nanodjango/commands.py now accepts these flags.
  • Dynamic Database Configuration: The Django.run() method in nanodjango/app.py was updated to dynamically configure an in-memory SQLite database when the flag is present.
  • Skipped Migrations: The database initialization logic now checks if an in-memory database is being used and skips the makemigrations, migrate, and createsuperuser steps accordingly.
  • Added Tests: A new test case was added to tests/test_run_runserver.py to verify that the --no-db flag prevents the creation of a database file and that the server runs correctly.

- Updated the `run` method in the Django class to accept a `no_db` flag.
- Modified the `run` command in the CLI to include the `--no-db` option.
- Added a test case to verify the functionality of running the server without a database.
@SmileyChris

Copy link
Copy Markdown
Contributor

See also: #88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants