migrations

package
v0.0.0-...-b718ee8 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MigrationList = []struct {
	ID          string
	Description string
	Apply       func(*mongo.Client) error
}{
	{
		ID:          "2024_11_10_create_users_collection",
		Description: "Create users collection with _id, username, email, password, created_at, updated_at fields",
		Apply:       createUsersCollection,
	},
	{
		ID:          "2024_11_09_unique_user_constraints",
		Description: "Add unique constraints on username, email, and id fields in users collection",
		Apply:       addUniqueUserConstraints,
	},
	{
		ID:          "2024_11_10_create_tasks_collection",
		Description: "Create tasks collection with _id, title, description, completed, status, due_date, user_id, created_at, updated_at fields",
		Apply:       createTasksCollection,
	},
}

MigrationList holds all migrations in order of application

Functions

func ApplyMigrations

func ApplyMigrations(client *mongo.Client) error

ApplyMigrations checks and applies any pending migrations.

Types

type Migration

type Migration struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	MigrationID string             `bson:"migration_id"` // Unique ID for each migration
	Description string             `bson:"description"`
	AppliedAt   time.Time          `bson:"applied_at"`
}

Jump to

Keyboard shortcuts

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