night

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

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

Go to latest
Published: Apr 16, 2025 License: MIT Imports: 1 Imported by: 0

README

Night image

Night

Night a minimal utra fast database seed tool

Get up and running with night is seconds, the ultimate database seed tool out there. Night uses Golang for its core implementaion and some of your favortie database drivers including sqlite3 and postgres.

Install
go install github.com/hector3211/night@latest
Get Started

Create a file and call it seed.sql or seed.go fill it out to your liking and point Night to it.

SQL Example
--  Sqlite Version
CREATE TABLE IF NOT EXISTS user (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    username TEXT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

-- Postgres Version
CREATE TABLE IF NOT EXISTS users (
    id SERIAL PRIMARY KEY,
    username VARCHAR(50),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX idx_users_usersname ON users(username);

INSERT INTO users (username) VALUES ( 'maddog' );
Go Example

// User Table
type Users struct {
    ID int `night:"primary_key"`
    Name string `night:"notnull"`
    Email string `night:"unique"`
    EmailVerified bool `night:"nullable"`
}

Then run this command to start seeding

night seed

Seed using flags

night seed -d poostgres -p ./seed.sql  -u postgres://postgres:postgres@localhost:5432/mydb

Seed using flags and Golang

night seed -d poostgres -p ./seed.go  -u postgres://postgres:postgres@localhost:5432/mydb
Database Drivers Supported

✅ sqlite3 ✅ postgres 🟧 mysql

Documentation

Overview

Copyright © 2024 Hector Orpesa

Directories

Path Synopsis
cmd
ui
pkg

Jump to

Keyboard shortcuts

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