{"id":15980221,"url":"https://github.com/appcypher/pgseeder","last_synced_at":"2025-04-04T18:44:13.671Z","repository":{"id":48462961,"uuid":"362126893","full_name":"appcypher/pgseeder","owner":"appcypher","description":"A Seeder for Postgres Databases","archived":false,"fork":false,"pushed_at":"2021-07-02T12:49:50.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-05T15:03:24.020Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appcypher.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}},"created_at":"2021-04-27T13:42:38.000Z","updated_at":"2022-07-22T23:51:43.000Z","dependencies_parsed_at":"2022-09-07T03:31:21.845Z","dependency_job_id":null,"html_url":"https://github.com/appcypher/pgseeder","commit_stats":null,"previous_names":["gigamono/pgseeder"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appcypher%2Fpgseeder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appcypher%2Fpgseeder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appcypher%2Fpgseeder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appcypher%2Fpgseeder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appcypher","download_url":"https://codeload.github.com/appcypher/pgseeder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234850,"owners_count":20905852,"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":[],"created_at":"2024-10-08T00:02:45.755Z","updated_at":"2025-04-04T18:44:13.650Z","avatar_url":"https://github.com/appcypher.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ePGSEEDER\u003c/h1\u003e\n\nA seeder for adding and removing seeds from a Postgres database.\n\n## \u003csup\u003e\u003csup\u003e🛠\u003c/sup\u003e\u003c/sup\u003e INSTALLATION\n\n- Clone pgseeder repo and cd into the created folder\n\n  ```sh\n  git clone https://github.com/gigamono/pgseeder\n  ```\n\n  ```sh\n  cd pgseeder\n  ```\n\n- Build the binary.\n\n  ```sh\n  go build cmd/pgseeder.go\n  ```\n\n- Add the binary to system path and run `pgseeder -h` command\n\n## \u003csup\u003e\u003csup\u003e📜\u003c/sup\u003e\u003c/sup\u003e  USAGE\n\n### CREATING SEED FILES\n\n- Pgseeder expects `.sql` filenames to be ordered based on their dependency.\n\n  The ordering format has to be a prefix and an integer.\n\n  For example:\n\n  ```\n  01_users.sql\n  ```\n\n  ```\n  20210702_users.sql\n  ```\n\n- You can use Pgseeder to create a timestamped `.sql` file.\n\n  ```sh\n  pgseeder --create \"users\"\n  ```\n\n  This generates a timestamped `.sql` file similar to this: `20210620150637_users.sql`\n\n\u003e \u003csup\u003e\u003csup\u003eℹ️\u003c/sup\u003e\u003c/sup\u003e Ordering allows Pgseeder to avoid foreign key constraint errors when adding or removing all seeds.\n\n### ADDING SEEDS TO THE DATABASE\n\n- To add seeds from a `20210620150637_users.sql` file, you run following command:\n\n  ```sh\n  pgseeder -c \"postgres://postgres@localhost:5432/resourcedb?sslmode=disable\" --add users\n  ```\n\n  The `-c` is needed to connect to the database. It takes postgres connection string.\n\n- You can also run all the `.sql` files in the current directory with the `--add-all` flag\n\n  ```sh\n  pgseeder -c \"postgres://postgres@localhost:5432/resourcedb?sslmode=disable\" --add-all\n  ```\n\n- You can specify a directory where the `.sql` files live with `-d` flag\n\n  ```sh\n  pgseeder -c \"postgres://postgres@localhost:5432/resourcedb?sslmode=disable\" --add-all -d \"./seeds\"\n  ```\n\n\u003e \u003csup\u003e\u003csup\u003eℹ️\u003c/sup\u003e\u003c/sup\u003e To support removing seeds later, Pgseeder expects the `.sql` filename to correspond to seeded table's name.\n\n\n\u003e \u003csup\u003e\u003csup\u003e⚠\u003c/sup\u003e\u003c/sup\u003e If multiple tables are seeded in a `.sql` file, Pgseeder will only recognise the one that matches the filename.\n\n\n### REMOVING SEEDS FROM THE DATABASE\n\n- Here is how to remove seeds from `users` table.\n\n  ```sh\n  pgseeder -c \"postgres://postgres@localhost:5432/resourcedb?sslmode=disable\" --remove users\n  ```\n\n- To remove all seeds.\n\n  ```sh\n  pgseeder -c \"postgres://postgres@localhost:5432/resourcedb?sslmode=disable\" --remove-all\n  ```\n\n### SEED KEYS\n\n- By default Pgseeder stores the `id` (if there is one) of the seed which it uses later to remove it.\n\n- Sometimes the primary key is not `id`. You can specify the primary key with `-k` flag.\n\n  ```sh\n  pgseeder -c \"postgres://postgres@localhost:5432/resourcedb?sslmode=disable\" --add users -k \"user_id\"\n  ```\n\n- And to uniquely identify seeds using composite keys, you separate them by colons, commas or spaces.\n\n  ```sh\n  pgseeder -c \"postgres://postgres@localhost:5432/resourcedb?sslmode=disable\" --add x_memberships -k \"user_id, workspace_id\"\n  ```\n\n\n## \u003csup\u003e\u003csup\u003e💀\u003c/sup\u003e\u003c/sup\u003e CURRENT LIMITATIONS\n\n- Only supports `.sql` files.\n\n- Does not support seeding multiple tables in a single `.sql` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappcypher%2Fpgseeder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappcypher%2Fpgseeder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappcypher%2Fpgseeder/lists"}