Skip to content

Commit 7cd15bf

Browse files
committed
chore: README
1 parent c5ee5bd commit 7cd15bf

File tree

3 files changed

+32
-81
lines changed

3 files changed

+32
-81
lines changed

README.md

Lines changed: 32 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,82 +4,50 @@ This repository demonstrates how to use [pgschema](https://www.pgschema.com/) wi
44

55
## Overview
66

7-
This repository contains two workflows:
8-
1. **Single File Workflow** - For projects with all schema definitions in one file
9-
2. **Multi File Workflow** - For projects with schema split across multiple SQL files
7+
### Plan Workflows (Pull Requests)
8+
9+
- **Single File Plan** - Shows migration plan for single-file schemas
10+
- **Multi File Plan** - Shows migration plan for multi-file schemas
11+
12+
Plan workflows automatically:
1013

11-
Both workflows automatically:
1214
- Run `pgschema plan` when a PR modifies schema files
1315
- Post the migration plan as a comment on the PR
1416
- Update the comment if the PR is synchronized with new changes
1517

18+
### Apply Workflows (Main Branch)
19+
20+
- **Single File Apply** - Applies schema changes for single-file approach
21+
- **Multi File Apply** - Applies schema changes for multi-file approach
22+
23+
Apply workflows automatically:
24+
25+
- Run `pgschema apply` when changes are pushed to main branch
26+
- Use `--auto-approve` flag for automated deployment
27+
- Apply changes to a test PostgreSQL 17 container
28+
- Report success or failure with detailed logs
29+
1630
## Setup
1731

18-
### 1. GitHub Secrets
32+
### GitHub Secrets
1933

20-
No secrets required! Both workflows use a PostgreSQL 17 test container for demonstration purposes, making them fully self-contained.
34+
No secrets required! Both workflows start a PostgreSQL 17 test container for demonstration purposes, making them fully self-contained.
2135

22-
### 2. Schema Organization
36+
### Schema Organization
2337

2438
#### Single File Approach
25-
- Place your complete schema in `singlefile/schema.sql`
39+
40+
- Place your complete schema in `singlefile/schema.sql`. This is generated by `pgschema dump --host localhost --user postgres --password testpwd1 --db employee --file schema.sql`.
2641
- All tables, indexes, functions, and triggers in one file
27-
- Uses PostgreSQL 17 test container (no external database needed)
28-
- Compares current branch schema against main branch schema
29-
- Workflow: `.github/workflows/pgschema-plan-single.yml`
42+
- Plan workflow: `.github/workflows/pgschema-singlefile-plan.yml`
43+
- Apply workflow: `.github/workflows/pgschema-singlefile-apply.yml`
3044

3145
#### Multi File Approach
32-
- Place SQL files in the `multifile/` directory
46+
47+
- Place SQL files in the `multifile/` directory. This is generated by `pgschema dump --host localhost --user postgres --password testpwd1 --db employee --multi-file --file main.sql`
3348
- Uses `main.sql` as the entry point with psql `\i` directives
34-
- Organize files by type in subdirectories (tables/, functions/, views/, etc.)
35-
- Each file contains a specific database object
36-
- Uses PostgreSQL 17 test container (no external database needed)
37-
- Compares current branch schema against main branch schema
38-
- Workflow: `.github/workflows/pgschema-plan-multi.yml`
39-
40-
## Usage
41-
42-
1. Choose your schema approach (single file or multi file)
43-
2. Create or update schema files in the appropriate directory
44-
3. Open a pull request
45-
4. The relevant workflow will automatically run and comment with the migration plan
46-
5. Review the plan to understand what changes will be applied
47-
6. The comment will be updated if you push more changes to the PR
48-
49-
## Example Schemas
50-
51-
### Single File Example
52-
See `singlefile/schema.sql` for a complete schema with:
53-
- Users and posts tables
54-
- Foreign key relationships
55-
- Indexes for performance
56-
- Triggers for auto-updating timestamps
57-
58-
### Multi File Example
59-
See `multifile/` directory for a comprehensive schema organization:
60-
- `main.sql` - Entry file using psql `\i` directives to include other files
61-
- `domains/` - Custom domain types (email_address, positive_integer)
62-
- `types/` - Custom types (address, order_status, user_status)
63-
- `sequences/` - Sequence definitions (global_id_seq, order_number_seq)
64-
- `tables/` - Table definitions (users, orders)
65-
- `functions/` - Database functions (get_user_count, update_timestamp)
66-
- `procedures/` - Stored procedures (cleanup_orders, update_status)
67-
- `views/` - Database views (order_details, user_summary)
68-
69-
This structure demonstrates how to organize complex schemas across multiple files and directories.
70-
71-
## Security Notes
72-
73-
- Both workflows use isolated PostgreSQL 17 test containers
74-
- No external database credentials required
75-
- Safe for demonstration and testing purposes
76-
- Containers are ephemeral and destroyed after each workflow run
77-
78-
## Next Steps
79-
80-
To apply migrations, you would typically:
81-
1. Review and approve the PR
82-
2. Run `pgschema apply` in your deployment pipeline
83-
3. Consider using `--auto-approve` flag for automated deployments
84-
85-
For more information, visit the [pgschema documentation](https://www.pgschema.com/).
49+
- Organize files by type in subdirectories (tables/, functions/, views/, etc.). Each file contains a specific database object
50+
- Plan workflow: `.github/workflows/pgschema-multifile-plan.yml`
51+
- Apply workflow: `.github/workflows/pgschema-multifile-apply.yml`
52+
53+
For more information, visit the [pgschema documentation](https://www.pgschema.com/).

multifile/README.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

singlefile/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)