Skip to content

Commit 896ee9e

Browse files
authored
Merge pull request #26 from he1senbrg/doc
Added migration management details to docs
2 parents 0975d3f + 2c43e7e commit 896ee9e

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ cargo shuttle run
4242

4343
### Documentation
4444

45-
Explore the [API documentation](/docs/docs.md) for detailed information and usage guidelines.
45+
Explore the [Documentation](/docs/docs.md) for detailed information and usage guidelines.
4646

4747
---
4848

docs/docs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# API Documentation
22

33
## Contents
4+
- [Managing Migrations](/docs/migrations.md)
45
- [GraphQL Queries](/docs/queries.md)
56
- [GraphQL Mutations](/docs/mutations.md)

docs/migrations.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Managing Migrations
2+
3+
## Contents
4+
- [Create Migrations](#create-migrations)
5+
- [Run Migrations](#run-migrations)
6+
7+
---
8+
9+
### Prerequisites
10+
1. Install `sql-cli`
11+
```bash
12+
cargo install sqlx-cli
13+
```
14+
15+
### Create Migrations
16+
17+
Run the following command to create migrations
18+
19+
```bash
20+
sqlx migrate add <migration_name>
21+
```
22+
23+
- Replace `<migration_name>` with a descriptive name for your migration, e.g.,`create_users_table`.
24+
- This will add a new migration file to the `migrations` directory.
25+
26+
---
27+
28+
### Run Migrations
29+
30+
Run the following command to apply migrations to your local database
31+
32+
```bash
33+
sqlx migrate run
34+
```
35+
36+
---
37+
38+
### Notes
39+
- Look for logs confirming the migration ran successfully.
40+
- Never rename or alter migration files as their names and contents are used to track applied changes.

0 commit comments

Comments
 (0)