{"id":36508918,"url":"https://github.com/rrgmc/debefix","last_synced_at":"2026-01-14T13:03:01.593Z","repository":{"id":198526404,"uuid":"699869356","full_name":"rrgmc/debefix","owner":"rrgmc","description":"Go library to seed database data and/or create fixtures for DB tests, with data relationships.","archived":false,"fork":false,"pushed_at":"2024-11-30T10:12:55.000Z","size":223,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-12T05:01:48.475Z","etag":null,"topics":["database","fixtures","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","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/rrgmc.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}},"created_at":"2023-10-03T13:58:06.000Z","updated_at":"2025-05-12T14:46:10.000Z","dependencies_parsed_at":"2024-06-18T12:58:04.208Z","dependency_job_id":"f77455ba-5f74-419a-97bf-0dabfc73a4c0","html_url":"https://github.com/rrgmc/debefix","commit_stats":null,"previous_names":["rangelreale/debefix"],"tags_count":123,"template":false,"template_full_name":null,"purl":"pkg:github/rrgmc/debefix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrgmc%2Fdebefix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrgmc%2Fdebefix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrgmc%2Fdebefix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrgmc%2Fdebefix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rrgmc","download_url":"https://codeload.github.com/rrgmc/debefix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrgmc%2Fdebefix/sbom","scorecard":{"id":786660,"data":{"date":"2025-08-11","repo":{"name":"github.com/rrgmc/debefix","commit":"4244e5ee8efffa35e5e34542b66fc4d9a3b0475a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.2,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Warn: topLevel 'contents' permission set to 'write': .github/workflows/release.yml:9","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/rrgmc/debefix/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/rrgmc/debefix/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/rrgmc/debefix/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/rrgmc/debefix/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/rrgmc/debefix/release.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:12"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T06:16:49.765Z","repository_id":198526404,"created_at":"2025-08-23T06:16:49.765Z","updated_at":"2025-08-23T06:16:49.765Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["database","fixtures","go","golang"],"created_at":"2026-01-12T02:33:16.815Z","updated_at":"2026-01-14T13:03:01.588Z","avatar_url":"https://github.com/rrgmc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# debefix - Database seeding and fixtures\n[![GoDoc](https://godoc.org/github.com/rrgmc/debefix/v2?status.png)](https://godoc.org/github.com/rrgmc/debefix/v2)\n\n`debefix` is a Go library to seed database data and/or create fixtures for DB tests.\n\nTables can reference each other using string ids (called `RefID`), and generated fields (like database auto increment or\ngenerated UUID) are supported and can be resolved and used by other table's references.\n\nDependencies between tables can be detected automatically by reference ids, or manually. This is used to generate a\ndependency graph and output the insert statements in the correct order.\n\nRow values can reference each other using `Value` or `ValueMultiple` interface implementations. They are referenced\nafter they are resolved, so it can reference values generated on execution like autoincrement fields.\n\n## Install\n\n```shell\ngo get -u github.com/rrgmc/debefix/v2\n```\n\n## Goals\n\n- For developer seeding or test fixtures, not for inserting a huge amount of records.\n\n## Example\n\n```go\nimport (\n    \"context\"\n    \"os\"\n\n    \"github.com/rrgmc/debefix-db/v2/sql\"\n    \"github.com/rrgmc/debefix-db/v2/sql/postgres\"\n    \"github.com/rrgmc/debefix/v2\"\n)\n\nfunc ExampleResolve() {\n    ctx := context.Background()\n    data := debefix.NewData()\n\n    tableTags := debefix.TableName(\"public.tags\")\n    tableUsers := debefix.TableName(\"public.users\")\n    tablePosts := debefix.TableName(\"public.posts\")\n    tablePostTags := debefix.TableName(\"public.post_tags\")\n\n    data.AddValues(tableTags,\n        debefix.MapValues{\n            // this field value will be generated at resolve time, for example as a database autoincrement.\n            \"tag_id\": debefix.ResolveValueResolve(),\n            // sets the RefID to be targeted by `ValueRefID(tableTags, \"go\", \"tag_id\")`. Field is not added to the row values.\n            \"_refid\": debefix.SetValueRefID(\"go\"),\n            \"name\":   \"Go\",\n            // set the value as the resolver base time plus 1 hour.\n            \"created_at\": debefix.ValueBaseTimeAdd(debefix.WithAddHours(1)),\n            \"updated_at\": debefix.ValueBaseTimeAdd(debefix.WithAddHours(1)),\n        },\n        debefix.MapValues{\n            \"tag_id\":     debefix.ResolveValueResolve(),\n            \"_refid\":     debefix.SetValueRefID(\"javascript\"),\n            \"name\":       \"JavaScript\",\n            \"created_at\": debefix.ValueBaseTimeAdd(debefix.WithAddHours(1), debefix.WithAddMinutes(2)),\n            \"updated_at\": debefix.ValueBaseTimeAdd(debefix.WithAddHours(1), debefix.WithAddMinutes(2)),\n        },\n        debefix.MapValues{\n            \"tag_id\":     debefix.ResolveValueResolve(),\n            \"_refid\":     debefix.SetValueRefID(\"cpp\"),\n            \"name\":       \"C++\",\n            \"created_at\": debefix.ValueBaseTimeAdd(debefix.WithAddHours(1), debefix.WithAddMinutes(2)),\n            \"updated_at\": debefix.ValueBaseTimeAdd(debefix.WithAddHours(1), debefix.WithAddMinutes(2)),\n        },\n    )\n\n    data.AddValues(tableUsers,\n        debefix.MapValues{\n            \"user_id\": 1, // fixed ID, not generated by the database\n            // sets the RefID to be targeted by `ValueRefID(tableUsers, \"johndoe\", \"user_id\")`. Field is not added to the row values.\n            \"_refid\":     debefix.SetValueRefID(\"johndoe\"),\n            \"name\":       \"John Doe\",\n            \"email\":      \"john@example.com\",\n            \"created_at\": debefix.ValueBaseTimeAdd(debefix.WithAddMinutes(30)),\n            \"updated_at\": debefix.ValueBaseTimeAdd(debefix.WithAddMinutes(30)),\n        },\n        debefix.MapValues{\n            \"user_id\":    2,\n            \"_refid\":     debefix.SetValueRefID(\"janedoe\"),\n            \"name\":       \"Jane Doe\",\n            \"email\":      \"jane@example.com\",\n            \"created_at\": debefix.ValueBaseTimeAdd(debefix.WithAddMinutes(30)),\n            \"updated_at\": debefix.ValueBaseTimeAdd(debefix.WithAddMinutes(30)),\n        },\n    )\n\n    // AddWithID returns an internal ID reference that can be used later.\n    post1IID := data.AddWithID(tablePosts,\n        debefix.MapValues{\n            \"post_id\": debefix.ValueUUIDRandom(), // generates a random UUID value.\n            \"title\":   \"First post\",\n            \"text\":    \"This is the text of the first post\",\n            // returns the value of the \"user_id\" field of the row with the \"johndoe\" RefID in the tableUsers table.\n            // this also adds a dependency between \"posts\" and \"users\", so \"users\" will always be resolved before \"posts\".\n            \"user_id\":    debefix.ValueRefID(tableUsers, \"johndoe\", \"user_id\"),\n            \"created_at\": debefix.ValueBaseTimeAdd(debefix.WithAddHours(2)),\n            \"updated_at\": debefix.ValueBaseTimeAdd(debefix.WithAddHours(2)),\n        })\n    post2IID := data.AddWithID(tablePosts,\n        debefix.MapValues{\n            \"post_id\": debefix.ValueUUIDRandom(), // generates a random UUID value.\n            // data is inserted in the order they were added, so it is possible to reference another row in the same table.\n            \"parent_post_id\": post1IID.ValueForField(\"post_id\"),\n            \"title\":          \"Second post\",\n            \"text\":           \"This is the text of the second post\",\n            \"user_id\":        debefix.ValueRefID(tableUsers, \"johndoe\", \"user_id\"),\n            \"created_at\":     debefix.ValueBaseTimeAdd(debefix.WithAddHours(2)),\n            \"updated_at\":     debefix.ValueBaseTimeAdd(debefix.WithAddHours(2)),\n        },\n    )\n\n    data.AddValues(debefix.TableName(tablePostTags),\n        debefix.MapValues{\n            // returns the value of the \"post_id\" field of the row referenced by \"post1IID\", after it was resolved.\n            \"post_id\": post1IID.ValueForField(\"post_id\"),\n            // tag_id is generated by the database, so the value will be resolved before being set here.\n            \"tag_id\": debefix.ValueRefID(tableTags, \"go\", \"tag_id\"),\n        },\n        debefix.MapValues{\n            \"post_id\": post1IID.ValueForField(\"post_id\"),\n            \"tag_id\":  debefix.ValueRefID(tableTags, \"cpp\", \"tag_id\"),\n        },\n        debefix.MapValues{\n            // returns the value of the \"post_id\" field of the row referenced by \"post2IID\", after it was resolved.\n            \"post_id\": post2IID.ValueForField(\"post_id\"),\n            \"tag_id\":  debefix.ValueRefID(tableTags, \"javascript\", \"tag_id\"),\n        },\n    )\n\n    if data.Err() != nil {\n        panic(data.Err())\n    }\n\n    // outputs all generated queries\n    qi := sql.NewDebugQueryInterface(os.Stdout)\n\n    // resolve the rows using a SQL query resolver.\n    _, err := debefix.Resolve(ctx, data,\n        postgres.ResolveFunc(qi))\n    if err != nil {\n        panic(err)\n    }\n\n    // =============== public.tags ===============\n    // INSERT INTO \"public.tags\" (\"created_at\", \"name\", \"updated_at\") VALUES ($1, $2, $3) RETURNING \"tag_id\"\n    // $$ ARGS: [0:\"2024-11-29 08:30:16.028185 -0300 -03 m=+3600.002859876\"] [1:\"Go\"] [2:\"2024-11-29 08:30:16.028185 -0300 -03 m=+3600.002859876\"]\n    // --------------------INSERT INTO \"public.tags\" (\"created_at\", \"name\", \"updated_at\") VALUES ($1, $2, $3) RETURNING \"tag_id\"\n    // $$ ARGS: [0:\"2024-11-29 08:32:16.028185 -0300 -03 m=+3720.002859876\"] [1:\"JavaScript\"] [2:\"2024-11-29 08:32:16.028185 -0300 -03 m=+3720.002859876\"]\n    // --------------------INSERT INTO \"public.tags\" (\"created_at\", \"name\", \"updated_at\") VALUES ($1, $2, $3) RETURNING \"tag_id\"\n    // $$ ARGS: [0:\"2024-11-29 08:32:16.028185 -0300 -03 m=+3720.002859876\"] [1:\"C++\"] [2:\"2024-11-29 08:32:16.028185 -0300 -03 m=+3720.002859876\"]\n    // =============== public.users ===============\n    // INSERT INTO \"public.users\" (\"created_at\", \"email\", \"name\", \"updated_at\", \"user_id\") VALUES ($1, $2, $3, $4, $5)\n    // $$ ARGS: [0:\"2024-11-29 08:00:16.028185 -0300 -03 m=+1800.002859876\"] [1:\"john@example.com\"] [2:\"John Doe\"] [3:\"2024-11-29 08:00:16.028185 -0300 -03 m=+1800.002859876\"] [4:\"1\"]\n    // --------------------INSERT INTO \"public.users\" (\"created_at\", \"email\", \"name\", \"updated_at\", \"user_id\") VALUES ($1, $2, $3, $4, $5)\n    // $$ ARGS: [0:\"2024-11-29 08:00:16.028185 -0300 -03 m=+1800.002859876\"] [1:\"jane@example.com\"] [2:\"Jane Doe\"] [3:\"2024-11-29 08:00:16.028185 -0300 -03 m=+1800.002859876\"] [4:\"2\"]\n    // =============== public.posts ===============\n    // INSERT INTO \"public.posts\" (\"created_at\", \"post_id\", \"text\", \"title\", \"updated_at\", \"user_id\") VALUES ($1, $2, $3, $4, $5, $6)\n    // $$ ARGS: [0:\"2024-11-29 09:30:16.028185 -0300 -03 m=+7200.002859876\"] [1:\"91a27c77-ff00-4f3b-90d6-51e335b7ad36\"] [2:\"This is the text of the first post\"] [3:\"First post\"] [4:\"2024-11-29 09:30:16.028185 -0300 -03 m=+7200.002859876\"] [5:\"1\"]\n    // --------------------INSERT INTO \"public.posts\" (\"created_at\", \"parent_post_id\", \"post_id\", \"text\", \"title\", \"updated_at\", \"user_id\") VALUES ($1, $2, $3, $4, $5, $6, $7)\n    // $$ ARGS: [0:\"2024-11-29 09:30:16.028185 -0300 -03 m=+7200.002859876\"] [1:\"91a27c77-ff00-4f3b-90d6-51e335b7ad36\"] [2:\"c06a1f3e-3578-4b56-bf51-9fb949ae5dbf\"] [3:\"This is the text of the second post\"] [4:\"Second post\"] [5:\"2024-11-29 09:30:16.028185 -0300 -03 m=+7200.002859876\"] [6:\"1\"]\n    // =============== public.post_tags ===============\n    // INSERT INTO \"public.post_tags\" (\"post_id\", \"tag_id\") VALUES ($1, $2)\n    // $$ ARGS: [0:\"91a27c77-ff00-4f3b-90d6-51e335b7ad36\"] [1:\"223eca8c-d2c3-46ef-bb1f-d175916c97a2\"]\n    // --------------------INSERT INTO \"public.post_tags\" (\"post_id\", \"tag_id\") VALUES ($1, $2)\n    // $$ ARGS: [0:\"91a27c77-ff00-4f3b-90d6-51e335b7ad36\"] [1:\"d5c6e911-f38e-4cef-958b-cd5d8fc787f2\"]\n    // --------------------INSERT INTO \"public.post_tags\" (\"post_id\", \"tag_id\") VALUES ($1, $2)\n    // $$ ARGS: [0:\"c06a1f3e-3578-4b56-bf51-9fb949ae5dbf\"] [1:\"bd2d497f-af58-4338-a040-a24002492436\"]\n}\n```\n\n# Samples\n\n## Extra\n\n# License\n\nMIT\n\n### Author\n\nRangel Reale (rangelreale@gmail.com)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frrgmc%2Fdebefix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frrgmc%2Fdebefix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frrgmc%2Fdebefix/lists"}