{"id":26316847,"url":"https://github.com/nathanthorell/mssql-music-platform-db","last_synced_at":"2026-04-24T12:33:37.508Z","repository":{"id":196660750,"uuid":"694930147","full_name":"nathanthorell/mssql-music-platform-db","owner":"nathanthorell","description":"Sample database in SQL Server using Flyway schema migrations","archived":false,"fork":false,"pushed_at":"2025-05-05T02:38:15.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-05T07:39:23.082Z","etag":null,"topics":["flyway","sql-server","sqlfluff"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathanthorell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-22T01:46:58.000Z","updated_at":"2025-05-05T02:38:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2ec8641-44c7-4890-9988-9b2875924ad8","html_url":"https://github.com/nathanthorell/mssql-music-platform-db","commit_stats":null,"previous_names":["nathanthorell/mssql-music-platform-db"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nathanthorell/mssql-music-platform-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanthorell%2Fmssql-music-platform-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanthorell%2Fmssql-music-platform-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanthorell%2Fmssql-music-platform-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanthorell%2Fmssql-music-platform-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathanthorell","download_url":"https://codeload.github.com/nathanthorell/mssql-music-platform-db/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanthorell%2Fmssql-music-platform-db/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32224118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T10:26:35.452Z","status":"ssl_error","status_checked_at":"2026-04-24T10:25:27.643Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flyway","sql-server","sqlfluff"],"created_at":"2025-03-15T13:16:59.122Z","updated_at":"2026-04-24T12:33:37.502Z","avatar_url":"https://github.com/nathanthorell.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Music Platform Example Database\n\nAn example database in MSSQL using Flyway for schema migrations\n\n## Continuous Integration\n\n### Automated SQL Quality and Migration Testing\n\nAll SQL changes are automatically validated through a comprehensive CI pipeline when pull requests are created or updated. The workflow only triggers when .sql files are modified, optimizing resource usage.\n\n**CI Pipeline Flow:**\n\n1. **SQL Linting** - Validates syntax and catches parsing errors with SQLFluff\n1. **SQL Formatting** - Auto-formats code to maintain consistency (only if linting passes)\n1. **Migration Testing** - Tests all Flyway migrations against a fresh database server container (only if SQL quality checks pass)\n\n### Pipeline Details\n\n#### Step 1: SQL Linting\n\n- Runs SQLFluff lint on all changed SQL files\n- **Fails fast** on syntax errors (like `FORM` instead of `FROM`)\n- Prevents expensive migration testing when SQL has basic errors\n- Uses the `.sqlfluff` configuration for validation rules\n\n#### Step 2: SQL Formatting\n\n- Auto-formats SQL files using SQLFluff to ensure consistent style\n- Applies fixes for indentation, spacing, keyword casing, etc.\n- **Automatically commits formatting changes** back to your branch\n- Comments on PR when formatting is applied\n- Only runs if linting passes successfully\n\n#### Step 3: Migration Testing\n\n- Spins up a fresh database server container for testing\n- Creates a clean test database\n- Runs all migrations in sequence using Flyway\n- Validates migration integrity and consistency\n- **Only runs if both SQL linting and formatting complete successfully**\n\n### Resource Optimization\n\nThe pipeline is designed to fail fast and save CI resources:\n\n- ❌ **Syntax errors** → Pipeline stops at linting\n- ✅ **Formatting issues** → Auto-fixed, then continues to migration testing\n- ✅ **Clean SQL** → Full migration testing with Docker containers\n\nThis ensures expensive database containers only spin up for valid, properly formatted SQL.\n\n### SQL Code Formatting\n\nSQLFluff automatically formats SQL files to maintain code consistency:\n\n- Runs on all SQL file changes in pull requests\n- Uses the `.sqlfluff` configuration in this repo\n- Automatically commits formatting fixes back to your branch\n- Ensures consistent code style across the team\n\n**Bypassing SQLFluff when needed:**\nIn rare cases where SQLFluff's formatting is incorrect or conflicts with valid SQL patterns, you can use inline comments:\n\n```sql\n-- Ignore specific rules on a line\nSELECT * FROM users; -- noqa: LT02,AL02\n\n-- Ignore all formatting on a line\nSELECT * FROM legacy_table; -- noqa\n\n-- Ignore rules for a block of code\n-- noqa:disable=LT02\nSELECT *\nFROM   weirdly_formatted_legacy_view\nWHERE  complex_condition;\n-- noqa:enable=LT02\n\n-- Ignore all formatting for a block\n-- noqa:disable\nSELECT * FROM\n    some_complex_query_that_needs_special_formatting;\n-- noqa:enable\n```\n\nUse these sparingly - they should be the exception, not the rule.\n\n## Local Environment Configuration\n\nExample of environment variables:\n\n```bash\nDB_HOST=localhost\nDB_PORT=1433\nDB_NAME=MusicPlatform\nexport FLYWAY_URL=\"jdbc:sqlserver://localhost:1433;databaseName=MusicPlatform;encrypt=false;trustServerCertificate=true\"\nexport FLYWAY_USER=sa\nexport FLYWAY_PASSWORD=YOUR_SECRET_PASSWORD_HERE\nREDGATE_DISABLE_TELEMETRY=true\n```\n\n## Create Local MSSQL Server and Database\n\n- For local migration testing you will need a local SQL Server DB instance\n- This is easy with Docker.  Example:\n\n    ```text\n    docker run -d -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD=TestPassword01 -v mssqldata:/var/opt/mssql -p 1433:1433 --name azuresqledge mcr.microsoft.com/azure-sql-edge:latest\n    ```\n\n- Flyway requires a database before it can connect.  To speed up this process for development iteration, I've added `create_db.zsh` which connects and checks if the database exists, if so it drops the database then creates a new empty one.\n\n## SQL Server Naming Conventions\n\nBelow establishes standard naming for SQL Server objects.\n\n### Tables\n\n- Table names should be singular, representing a single row\n- Don't embed data type into a name (e.g. PersonNameString)\n- Avoid repeating the table name in the column definition (e.g. use Name instead of Volunteer Name in the Volunteer table)\n- PascalCase (e.g. VolunteerNote)\n- Tables created only to establish many-to-many relationships should simply be the names of the two tables (e.g. StudentClass)\n  - Example: A Student can have many Classes, and a Class can have many Students\n\n### Views, Functions, and Procedures\n\nThese should be created as [Repeatable Migrations](https://flywaydb.org/documentation/concepts/migrations#repeatable-migrations).  Follow file naming for \"repeatableSqlMigrationPrefix\" and \"sqlMigrationSeparator\".\n\nFile Naming Example:\n\n- Views: R__schema_vw_MyView.sql\n- Functions: R__schema_f_MyFunction.sql\n- Procedures: R__schema_usp_MyProcedureName.sql\n\nSQL Object Naming Example:\n\n- Views: schema.vw_MyView\n- Functions: schema.f_MyFunction\n- Procedures: schema.usp_MyProcedureName\n\n### Constraint Prefixes\n\n- PK for primary key indexes (e.g. PK_Volunteer_VolunteerId)\n- UQ for unique indexes other than primary key (UQ_TableName_ColumnName)\n- IX for all other indexes (IX_TableName_ColumName)\n- FK for foreign constraints (FK_TableName_ReferencedTableName_ColumnName)\n- DF for Default constraints\n- CK for check constraints\n- CIX for clustered indexes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanthorell%2Fmssql-music-platform-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanthorell%2Fmssql-music-platform-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanthorell%2Fmssql-music-platform-db/lists"}