{"id":25453169,"url":"https://github.com/nlopes/database-schema","last_synced_at":"2026-04-14T06:04:56.644Z","repository":{"id":191218416,"uuid":"684295502","full_name":"nlopes/database-schema","owner":"nlopes","description":"This crate provides a simple way to dump a database structure to a file, in SQL format.","archived":false,"fork":false,"pushed_at":"2024-07-23T08:20:16.000Z","size":53,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-16T13:52:36.619Z","etag":null,"topics":["database","database-migration","database-schema","diesel","mysql","sqlite","sqlx"],"latest_commit_sha":null,"homepage":"https://docs.rs/database-schema","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nlopes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["nlopes"]}},"created_at":"2023-08-28T21:08:52.000Z","updated_at":"2024-11-21T05:28:18.000Z","dependencies_parsed_at":"2023-11-16T12:25:00.989Z","dependency_job_id":"0964d9cb-6fdf-4fba-a82b-0b28531e5fab","html_url":"https://github.com/nlopes/database-schema","commit_stats":null,"previous_names":["nlopes/database-schema"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/nlopes/database-schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlopes%2Fdatabase-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlopes%2Fdatabase-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlopes%2Fdatabase-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlopes%2Fdatabase-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nlopes","download_url":"https://codeload.github.com/nlopes/database-schema/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlopes%2Fdatabase-schema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31784255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: 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":["database","database-migration","database-schema","diesel","mysql","sqlite","sqlx"],"created_at":"2025-02-17T23:49:30.207Z","updated_at":"2026-04-14T06:04:56.618Z","avatar_url":"https://github.com/nlopes.png","language":"Rust","funding_links":["https://github.com/sponsors/nlopes"],"categories":[],"sub_categories":[],"readme":"# database-schema\n\n[![CI Status](https://github.com/nlopes/database-schema/workflows/Test/badge.svg)](https://github.com/nlopes/database-schema/actions)\n[![docs.rs](https://docs.rs/database-schema/badge.svg)](https://docs.rs/database-schema)\n[![crates.io](https://img.shields.io/crates/v/database-schema.svg)](https://crates.io/crates/database-schema)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nlopes/database-schema/blob/master/LICENSE)\n\nThis crate provides a simple way to dump a database structure to a file, in SQL\nformat.\n\nIt takes inspiration by the ruby on rails [schema dump].\n\n## Usage\n\n```rust,ignore\nuse std::path::PathBuf;\n\ndatabase_schema::generate_without_runtime_using_defaults!();\n```\n\n\n## Feature flags\n\n`database-schema` uses a set of [feature flags] to reduce the size of the libray and\ntherefore your binary. The way one should use this package is to pick the right\ncombination of feature flags for their use case. Below is a list of the available\nfeature flags and the combinations that are recommended for each use case.\n\n- `sqlite`: Enables SQLite support.\n- `postgres`: Enables PostgreSQL support.\n- `mysql`: Enables MySQL support.\n- `sqlx`: Enables [sqlx] support.\n- `diesel`: Enables [diesel] support.\n\n### Feature flag matrix\n| Database | Query builder | Runtime |\n|----------|---------------|---------|\n| `sqlite` | `sqlx`        | `runtime-async-std` |\n| `sqlite` | `sqlx`        | `runtime-tokio` |\n| `sqlite` | `diesel`      | |\n| `mysql`  | `sqlx`        | `runtime-async-std` |\n| `mysql`  | `sqlx`        | `runtime-tokio` |\n| `mysql`  | `diesel`      | |\n| `postgres` | `sqlx`      | `runtime-async-std` |\n| `postgres` | `sqlx`      | `runtime-tokio` |\n| `postgres` | `diesel`    | |\n\n### Combining feature flags\n\nThe following are the recommended feature flag combinations for each use case.\n\nFirst pick one of the following database feature flags:\n\n* `sqlite`\n* `mysql`\n* `postgres`\n\nThen pick one of the following database query building feature flags:\n\n* `sqlx`\n* `diesel`\n\nIf you're using `sqlx`, you also have to pick one of the following runtime feature flags:\n\n* `runtime-async-std`\n* `runtime-tokio`\n\n### Example\n\n```toml\n[dependencies]\ndatabase-schema = { version = \"0.1\", features = [\"sqlite\", \"sqlx\", \"runtime-async-std\"] }\n```\n\nalternatively, if you're using `diesel`:\n```toml\n[dependencies]\ndatabase-schema = { version = \"0.1\", features = [\"sqlite\", \"diesel\"] }\n```\n\n### Macros\n\nThis crate also provides a set of macros that can be used to generate the SQL\nstructure of a database at compile time. This is useful for generating the SQL from\n`build.rs`.\n\n\n```toml\n[dependencies]\ndatabase-schema = { version = \"0.1\", features = [\"sqlite\", \"diesel\", \"macros\"] }\n```\n\n```rust,ignore\nuse database_schema::generate_without_runtime;\n\nlet sql = generate_without_runtime!(\"./migrations\", \"structure.sql\");\n```\n\nThe above is strictly equivalent to calling:\n\n```rust,ignore\nuse database_schema::generate_without_runtime_using_defaults;\n\nlet sql = generate_without_runtime!();\n```\n\n## Customization\n\n```rust,ignore\nuse database_schema::DatabaseSchemaBuilder;\n\nlet migrations_path = \"db/migrations\";\nlet destination_path = \"db/structure.sql\";\n\n// This assumes you're using SQLite in memory.\n//\n// If you need to set up a `connection_url` you can use\n// `DatabaseSchemaBuilder::connection_url` before calling\n// `build()`.\n\nDatabaseSchemaBuilder::new()\n    .migrations_dir(migrations_path)?\n    .destination_path(destination_path)\n    .build()\n    .dump()\n    .await\n```\n\n[feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section\n[sqlx]: https://docs.rs/sqlx/latest/sqlx/\n[diesel]: https://docs.rs/diesel/latest/diesel/\n[schema dump]: https://guides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlopes%2Fdatabase-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnlopes%2Fdatabase-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlopes%2Fdatabase-schema/lists"}