atlas-provider-django


Nameatlas-provider-django JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-06-06 16:25:28
maintainerNone
docs_urlNone
authorYour Name
requires_python<4.0,>=3.11
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # atlas-provider-django

Load [Django](https://www.djangoproject.com/) models into an [Atlas](https://atlasgo.io) project.

### Use-cases
1. **Declarative migrations** - use a Terraform-like `atlas schema apply --env django` to apply your Django schema to the database.
2. **Automatic migration planning** - use `atlas migrate diff --env django` to automatically plan a migration from the current database version to the Django schema.

### Installation

Install Atlas for macOS or Linux by running:
```bash
curl -sSf https://atlasgo.sh | sh
```

See [atlasgo.io](https://atlasgo.io/getting-started#installation) for more installation options.

Install the provider by running:

```bash
pip install atlas-provider-django
```

### Configuration

Add the provider to your Django project's `INSTALLED_APPS` in `settings.py`:

```python
INSTALLED_APPS = [
    ...,
    'atlas_provider_django',
    ...
]
```

In your project directory, create a new file named `atlas.hcl` with the following contents:

```hcl
data "external_schema" "django" {
  program = [
    "python",
    "manage.py",
    "atlas-provider-django",
    "--dialect", "mysql" // mariadb | postgresql | sqlite | mssql
    // if you want to only load a subset of your app models, you can specify the apps by adding
    // "--apps", "app1", "app2", "app3"
  ]
}

env "django" {
  src = data.external_schema.django.url
  dev = "docker://mysql/8/dev"
  migration {
    dir = "file://migrations"
  }
  format {
    migrate {
      diff = "{{ sql . \"  \" }}"
    }
  }
}
```


### Usage

#### Apply

You can use the `atlas schema apply` command to plan and apply a migration of your database to your current Django schema.
This works by inspecting the target database and comparing it to the Django Apps models and creating a migration plan.
Atlas will prompt you to confirm the migration plan before applying it to the database.

```bash
atlas schema apply --env django -u "mysql://root:password@localhost:3306/mydb"
```
Where the `-u` flag accepts the [URL](https://atlasgo.io/concepts/url) to the
target database.

#### Diff

Atlas supports a [versioned migrations](https://atlasgo.io/concepts/declarative-vs-versioned#versioned-migrations) 
workflow, where each change to the database is versioned and recorded in a migration file. You can use the
`atlas migrate diff` command to automatically generate a migration file that will migrate the database
from its latest revision to the current Django schema.

```bash
atlas migrate diff --env django 
````

### Supported Databases

The provider supports the following databases:
* MySQL
* MariaDB
* PostgreSQL
* SQLite
* Microsoft SQL Server

### Issues

Please report any issues or feature requests in the [ariga/atlas](https://github.com/ariga/atlas/issues) repository.

### License

This project is licensed under the [Apache License 2.0](LICENSE).
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "atlas-provider-django",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/d4/9a/10b781b6ee049b761892eb39f98d6781dcb75536a4bc1c8ad3c8c8e6831b/atlas_provider_django-0.2.1.tar.gz",
    "platform": null,
    "description": "# atlas-provider-django\n\nLoad [Django](https://www.djangoproject.com/) models into an [Atlas](https://atlasgo.io) project.\n\n### Use-cases\n1. **Declarative migrations** - use a Terraform-like `atlas schema apply --env django` to apply your Django schema to the database.\n2. **Automatic migration planning** - use `atlas migrate diff --env django` to automatically plan a migration from the current database version to the Django schema.\n\n### Installation\n\nInstall Atlas for macOS or Linux by running:\n```bash\ncurl -sSf https://atlasgo.sh | sh\n```\n\nSee [atlasgo.io](https://atlasgo.io/getting-started#installation) for more installation options.\n\nInstall the provider by running:\n\n```bash\npip install atlas-provider-django\n```\n\n### Configuration\n\nAdd the provider to your Django project's `INSTALLED_APPS` in `settings.py`:\n\n```python\nINSTALLED_APPS = [\n    ...,\n    'atlas_provider_django',\n    ...\n]\n```\n\nIn your project directory, create a new file named `atlas.hcl` with the following contents:\n\n```hcl\ndata \"external_schema\" \"django\" {\n  program = [\n    \"python\",\n    \"manage.py\",\n    \"atlas-provider-django\",\n    \"--dialect\", \"mysql\" // mariadb | postgresql | sqlite | mssql\n    // if you want to only load a subset of your app models, you can specify the apps by adding\n    // \"--apps\", \"app1\", \"app2\", \"app3\"\n  ]\n}\n\nenv \"django\" {\n  src = data.external_schema.django.url\n  dev = \"docker://mysql/8/dev\"\n  migration {\n    dir = \"file://migrations\"\n  }\n  format {\n    migrate {\n      diff = \"{{ sql . \\\"  \\\" }}\"\n    }\n  }\n}\n```\n\n\n### Usage\n\n#### Apply\n\nYou can use the `atlas schema apply` command to plan and apply a migration of your database to your current Django schema.\nThis works by inspecting the target database and comparing it to the Django Apps models and creating a migration plan.\nAtlas will prompt you to confirm the migration plan before applying it to the database.\n\n```bash\natlas schema apply --env django -u \"mysql://root:password@localhost:3306/mydb\"\n```\nWhere the `-u` flag accepts the [URL](https://atlasgo.io/concepts/url) to the\ntarget database.\n\n#### Diff\n\nAtlas supports a [versioned migrations](https://atlasgo.io/concepts/declarative-vs-versioned#versioned-migrations) \nworkflow, where each change to the database is versioned and recorded in a migration file. You can use the\n`atlas migrate diff` command to automatically generate a migration file that will migrate the database\nfrom its latest revision to the current Django schema.\n\n```bash\natlas migrate diff --env django \n````\n\n### Supported Databases\n\nThe provider supports the following databases:\n* MySQL\n* MariaDB\n* PostgreSQL\n* SQLite\n* Microsoft SQL Server\n\n### Issues\n\nPlease report any issues or feature requests in the [ariga/atlas](https://github.com/ariga/atlas/issues) repository.\n\n### License\n\nThis project is licensed under the [Apache License 2.0](LICENSE).",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "0.2.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ec9b8d9a10d0aabaf10257c062160252a636bc2e3f12babd71c35606c3639b3f",
                "md5": "11a4a6dbaba7a4018f879063162fedf5",
                "sha256": "09b85caa64dbab5c1e2f2248d00614883cdf4c31a5700448f7fc384b3bc66829"
            },
            "downloads": -1,
            "filename": "atlas_provider_django-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "11a4a6dbaba7a4018f879063162fedf5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 10845,
            "upload_time": "2024-06-06T16:25:26",
            "upload_time_iso_8601": "2024-06-06T16:25:26.285030Z",
            "url": "https://files.pythonhosted.org/packages/ec/9b/8d9a10d0aabaf10257c062160252a636bc2e3f12babd71c35606c3639b3f/atlas_provider_django-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d49a10b781b6ee049b761892eb39f98d6781dcb75536a4bc1c8ad3c8c8e6831b",
                "md5": "3cfe1f3550470f3144db337d5bb82479",
                "sha256": "b2490c3a1e63295abc8368a905491aab9a41c66520bb6fc314e5f428db720594"
            },
            "downloads": -1,
            "filename": "atlas_provider_django-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3cfe1f3550470f3144db337d5bb82479",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 9110,
            "upload_time": "2024-06-06T16:25:28",
            "upload_time_iso_8601": "2024-06-06T16:25:28.122792Z",
            "url": "https://files.pythonhosted.org/packages/d4/9a/10b781b6ee049b761892eb39f98d6781dcb75536a4bc1c8ad3c8c8e6831b/atlas_provider_django-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-06 16:25:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "atlas-provider-django"
}
        
Elapsed time: 0.24500s