https://github.com/carneles/goseeder
Golang database seeder
https://github.com/carneles/goseeder
database database-migrations databases go golang migration migration-tool migrations mysql postgres postgresql seeder
Last synced: 7 months ago
JSON representation
Golang database seeder
- Host: GitHub
- URL: https://github.com/carneles/goseeder
- Owner: carneles
- License: apache-2.0
- Created: 2020-04-02T07:46:27.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2020-06-30T03:24:02.000Z (over 5 years ago)
- Last Synced: 2025-02-11T14:49:29.199Z (8 months ago)
- Topics: database, database-migrations, databases, go, golang, migration, migration-tool, migrations, mysql, postgres, postgresql, seeder
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.com/carneles/goseeder)
[](https://goreportcard.com/report/github.com/carneles/goseeder)# goseeder - Golang Database Seeder
This is a tool to seed data into database tables (like Laravel's `php artisan db:seed` and Node's `sequelize-cli seed`).## Data
The data that will be inserted into tables, should be placed in YAML formatted files. One YAML file represent one table and the order of files in the folder is respected.
Goseeder uses `INSERT IGNORE` (on MySQL) and `INSERT ... ON CONFLICT DO NOTHING` (on Postgres) commands, so it is pretty safe to re-run the application again and again on tables having primary key or unique indexes.This is the example of the YAML files:
```
schema: public
table: test
data:
- id: 5b5d2fec-fbdb-493a-aa39-85878da3e08e
name: one
created_at: now()
- id: c445876c-05bc-4479-b581-bcfd4356a9eb
name: two
created_at: now()
```Store this file inside a folder, for example in `/folder/to/data`:
```
/folder
/to
/data
01_first_data.yaml
02_second_data.yaml
```To execute:
```
goseeder seed -s /folder/to/data -d postgres://user:password@server:port/dbname?sslmode=disable
```