{"id":16703530,"url":"https://github.com/kurtbuilds/sqlmo","last_synced_at":"2025-03-21T20:32:14.568Z","repository":{"id":65126752,"uuid":"582458077","full_name":"kurtbuilds/sqlmo","owner":"kurtbuilds","description":"SQL data primitives. Use it to generate SQL queries, auto-generate SQL migrations, and more.","archived":false,"fork":false,"pushed_at":"2025-01-26T14:25:14.000Z","size":225,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T04:51:20.445Z","etag":null,"topics":["orm","postgresql","rust","sql"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/sqlmo","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kurtbuilds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-12-26T22:40:39.000Z","updated_at":"2025-03-13T03:14:51.000Z","dependencies_parsed_at":"2023-07-14T08:56:53.473Z","dependency_job_id":"e9e4ff27-7595-4a12-9391-2d0252e933da","html_url":"https://github.com/kurtbuilds/sqlmo","commit_stats":{"total_commits":84,"total_committers":1,"mean_commits":84.0,"dds":0.0,"last_synced_commit":"968e0d3492cdf94006422ff82bb54d2783e92fa6"},"previous_names":["kurtbuilds/sqldiff"],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurtbuilds%2Fsqlmo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurtbuilds%2Fsqlmo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurtbuilds%2Fsqlmo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurtbuilds%2Fsqlmo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kurtbuilds","download_url":"https://codeload.github.com/kurtbuilds/sqlmo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244865883,"owners_count":20523421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["orm","postgresql","rust","sql"],"created_at":"2024-10-12T19:08:38.420Z","updated_at":"2025-03-21T20:32:14.144Z","avatar_url":"https://github.com/kurtbuilds.png","language":"Rust","readme":"\u003cdiv id=\"top\"\u003e\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/kurtbuilds/sqlmo/graphs/contributors\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/contributors/kurtbuilds/sqlmo.svg?style=flat-square\" alt=\"GitHub Contributors\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/kurtbuilds/sqlmo/stargazers\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/kurtbuilds/sqlmo.svg?style=flat-square\" alt=\"Stars\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/kurtbuilds/sqlmo/actions\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/kurtbuilds/sqlmo/test.yaml?style=flat-square\" alt=\"Build Status\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://crates.io/crates/sqlmo\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/d/sqlmo?style=flat-square\" alt=\"Downloads\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://crates.io/crates/sqlmo\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/sqlmo?style=flat-square\" alt=\"Crates.io\" /\u003e\n\u003c/a\u003e\n\n\u003c/p\u003e\n\n# `sqlmo`\n`sqlmo` is a set of primitives to represent SQL tables and queries. Use these primitives to:\n- **Auto-generate migrations**: Load SQL representations in a standardized form (`sqlmo::Schema`), calculate differences between \nschemas (`sqlmo::Migration`), and generate SQL to apply the migration (`sqlmo::Migration::to_sql`).\n- **Build SQL queries**: Represent SQL queries in a data model, to create APIs for query generation. Then, generate the\nSQL query. *Note: this library does not support parsing SQL queries (yet).*\n\nFor auto-generating migrations, there are a few built-in schema sources:\n- **Postgres**: [`sqlmo_sqlx`](./sqlmo_sqlx)\n- **OpenAPI v3**: [`sqlmo_openapi`](./sqlmo_openapi)\n\nIf you need another source, you should define a way to build a `sqlmo::Schema` from your data source, then use `sqlmo` \nto auto-generate migrations.\n\nCurrent tools that support this:\n\n- [`ormlite`](https://github.com/kurtbuilds/ormlite)\n\nIf you use this library, submit a PR to be added to this list.\n\n## Usage\n\nThis example reads the schema from a postgres database, defines an empty schema (which should be filled in),\nand then computes the migration to apply to the database.\n\n```rust\nuse sqlmo_sqlx::FromPostgres;\n\n#[tokio::main]\nasync fn main() {\n    let url = std::env::var(\"DATABASE_URL\").unwrap();\n    let mut conn = sqlx::postgres::PgConnection::connect(\u0026url).await?;\n    let current = Schema::try_from_postgres(\u0026mut conn, schema_name).await?;\n    let end_state = Schema::default(); // Load your end-state by manually defining it, or building it from another source\n    let migration = current.migrate_to(end_state, \u0026sqlmo::Options::default());\n    \n    for statement in migration.statements {\n        let statement = statement.to_sql(Dialect::Postgres);\n        println!(\"{}\", statement);\n    }\n}\n```\n\n# Roadmap\n\n- [ ] When calculating migrations, create commented out lines for column deletion\n- [ ] ? When calculating migrations, do alter column by calculating word distance between column names","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkurtbuilds%2Fsqlmo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkurtbuilds%2Fsqlmo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkurtbuilds%2Fsqlmo/lists"}