database

package
v0.0.0-...-f47fe49 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectAndMigrateDB

func ConnectAndMigrateDB(packageName string)

func ConnectToTestDB

func ConnectToTestDB(dbSchema string)

ConnectToTestDB connects to the test database, populates the "dao.DB" member, and runs a schema migration.

func CreateFixtures

func CreateFixtures(schema string)

CreateFixtures creates a new schema, migrates the schema and adds the required fixtures for the tests.

func CreateTestDB

func CreateTestDB()

CreateTestDB creates a test database. The function terminates the program with a code 0 if the creating is successful.

func DoneWithFixtures

func DoneWithFixtures(schema string)

DoneWithFixtures drops the schema and returns the "DB" object back to the "public" schema, in case any other tests need the database in the previous schema.

func DropSchema

func DropSchema(dbSchema string)

DropSchema drops the database schema entirely.

func MigrateSchema

func MigrateSchema()

MigrateSchema migrates all the models.

func UpdateTablesSequences

func UpdateTablesSequences()

UpdateTablesSequences loops over all the tables from the database to update the tables' sequences to the latest id. When inserting data with an ID, for example `INSERT INTO mytable(id, desc) VALUES (1, "My description")`, the sequence doesn't get updated because an explicit ID was given. Therefore, if in the subsequent calls the ID is omitted, this could lead to "unique constraint violation" errors because of a duplicate id.

Types

This section is empty.

Jump to

Keyboard shortcuts

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