greenseed
v0.1.8
Published
Greenseed is a small CLI tool to seed a PostgreSQL database from JSON files.
Readme
Greenseed
Greenseed is a small CLI tool to seed a PostgreSQL database from JSON files.
It reads data from JSON files and inserts it into database tables safely using primary keys.
Install
npm install greenseedUsage
greenseed pushOptions:
-c, --config <file> Config file (default: seed.config.json)
-d, --dbvar <name> Override database env var nameConfig file
Create a seed.config.json file.
Example:
{
"seedFileExtensions": [".json"],
"databaseUrlEnvVar": "DATABASE_URL",
"onMissingFile": "error",
"tables": [
{
"table": "users",
"schema": "public",
"primaryKeys": ["id"],
"source": "./data/users.json"
}
]
}JSON data
Each source file must be a JSON array.
Example:
[
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]Extra fields not in the table are ignored.
