-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add atlas migrate, move logic from handler to service, use dto, …
…add logic update
- Loading branch information
1 parent
2179f74
commit 1f94c1c
Showing
15 changed files
with
459 additions
and
197 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## Migrating with Atlas | ||
|
||
### Overview | ||
|
||
Atlas provides a streamlined way to manage and migrate database schemas effortlessly. Follow the steps below to set up and migrate your database using Atlas. | ||
|
||
### Step-by-Step Guide | ||
|
||
#### 1. Installation | ||
|
||
Firstly, install Atlas using the provided script: | ||
|
||
```bash | ||
curl -sSf https://atlasgo.sh | sh | ||
``` | ||
|
||
This will ensure you have the necessary tools to inspect and apply schema changes seamlessly. | ||
|
||
#### 2. Inspecting the Database and Generating Schema | ||
|
||
Whenever you make changes to your database schema, you must update your schema definition. To do this, inspect your current database setup and generate a `schema.sql` file: | ||
|
||
```bash | ||
atlas schema inspect \ | ||
--url "postgres://postgres:[email protected]:5432/postgres?search_path=public&sslmode=disable" \ | ||
--format "{{ sql . }}" > schema.sql | ||
``` | ||
|
||
This command fetches the current schema structure and outputs it to a `schema.sql` file, ensuring you have an up-to-date representation of your database schema. | ||
|
||
#### 3. Applying Schema Changes | ||
|
||
Once you've made the necessary updates to the `schema.sql` file, you can apply these changes to your database: | ||
|
||
```bash | ||
atlas schema apply \ | ||
--url "postgres://postgres:[email protected]:5432/postgres?&sslmode=disable" \ | ||
--to "file://schema.sql" \ | ||
--dev-url "docker://postgres/15" | ||
``` | ||
|
||
Here's what each parameter does: | ||
|
||
- `--url`: Specifies the connection URL to your target database where changes will be applied. | ||
- `--to`: Indicates the path to the `schema.sql` file containing the schema changes. | ||
- `--dev-url`: Provides a development URL for rolling back changes if necessary, ensuring a safe migration process. | ||
|
||
#### 4. Confirm and Apply | ||
|
||
After executing the migration command, review the changes to ensure everything aligns with your expectations. If satisfied, proceed with the migration to finalize the schema changes in your database. | ||
|
||
--- | ||
|
||
This improved documentation offers a structured approach, providing clarity on each step and its purpose. |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.