postgres

package
v0.0.0-...-09e72e1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package postgres is responsible for postgres database connections and initialization.

Index

Constants

This section is empty.

Variables

View Source
var PostgresQueries = []string{
	`CREATE TABLE IF NOT EXISTS Thread(
			Id uuid PRIMARY KEY,
			CreatedAt TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6) not null,
			Path varchar(255) not null UNIQUE
		)`,
	`CREATE TABLE IF NOT EXISTS Comment(
			Id uuid PRIMARY KEY,
			ThreadId uuid not null,
			Body text not null,
			Author varchar(255) not null,
			Confirmed bool not null default false,
			CreatedAt TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6) not null,
			ReplyTo uuid default null,
			DeletedAt TIMESTAMP(6) NULL,
			FOREIGN KEY(ThreadId) references Thread(Id)
		)`,
}

PostgresQueries represents a list of queries for initial table creation in Postgres

Functions

func CreateDatabase

func CreateDatabase(databaseConfig model.Database) (abstraction.Database, error)

CreateDatabase creates a database instance from the given config

func CreateTestDatabase

func CreateTestDatabase() abstraction.Database

CreateTestDatabase creates a test database

func ValidateConfig

func ValidateConfig(config model.Database) error

ValidateConfig validates the config for mysql

Types

This section is empty.

Jump to

Keyboard shortcuts

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