68 lines
2.1 KiB
Markdown
68 lines
2.1 KiB
Markdown
# SQL Server 2025 on Arch Linux (Docker) — localdev-ready
|
|
|
|
This repo provides a reproducible local SQL Server 2025 setup using Docker Compose,
|
|
plus convenience scripts for start/stop and database provisioning ("betanken").
|
|
|
|
## Layout / Mini Convention
|
|
|
|
- `compose.yml`
|
|
Docker Compose definition (SQL Server 2025 container).
|
|
- `.env.example` → copy to `.env` (not committed)
|
|
Holds your `MSSQL_SA_PASSWORD` and optional settings (port, edition).
|
|
- `scripts/`
|
|
Convenience scripts:
|
|
- `start.sh` — start container and wait until healthy
|
|
- `stop.sh` — stop container
|
|
- `down.sh` — remove container (keeps data on disk)
|
|
- `seed.sh` — run **all** `db/seed/*.sql` in order
|
|
- `migrate.sh` — run **all** `db/migrations/*.sql` in order
|
|
- `reset.sh` — delete `./data` (DESTROYS DB files), then start + seed + migrate
|
|
- `db/seed/` (idempotent)
|
|
Scripts that can be re-run safely. Typical content:
|
|
- create database(s) if missing
|
|
- create logins/users if missing
|
|
- minimal reference data
|
|
Naming: `001_*.sql`, `010_*.sql`, ...
|
|
- `db/migrations/` (forward-only)
|
|
Schema/data changes over time. Each file should be **run exactly once** per environment.
|
|
Naming: `2026-01-30_001_create_tables.sql`, `2026-02-05_002_add_index.sql`, ...
|
|
- `data/` (gitignored)
|
|
SQL Server data files mounted from the host.
|
|
- `backup/` (gitignored)
|
|
Place `.bak` files here if you want to restore from backups.
|
|
|
|
### Recommended workflow
|
|
|
|
1. Copy env:
|
|
```bash
|
|
cp .env.example .env
|
|
# edit .env (set strong password!)
|
|
```
|
|
|
|
2. Start server:
|
|
```bash
|
|
./scripts/start.sh
|
|
```
|
|
|
|
3. Provision baseline:
|
|
```bash
|
|
./scripts/seed.sh
|
|
./scripts/migrate.sh
|
|
```
|
|
|
|
4. Work with T-SQL (VS Code):
|
|
- Install extension: **SQL Server (mssql)** (Microsoft)
|
|
- Connect:
|
|
- Server: `localhost`
|
|
- Port: value from `MSSQL_PORT` (default 1433)
|
|
- Auth: SQL Login
|
|
- User: `sa`
|
|
- Password: `MSSQL_SA_PASSWORD`
|
|
- Open any `.sql` file and run **Execute Query**.
|
|
|
|
## Gitea-ready notes
|
|
|
|
- `.env` is ignored (secrets).
|
|
- `data/` and `backup/` are ignored (local artifacts).
|
|
- Use the issue/PR templates under `.gitea/` for consistent collaboration.
|