goseeder

command module
v0.0.0-...-e4dcd89 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

README

Build Status Go Report Card

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

Documentation

Overview

Copyright © 2020 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL