Get-Migration

Gets the migrations for all or specific databases.

Syntax

Get-Migration [-Database <String[]>] [-Environment <String>] [-ConfigFilePath <String>] [-Include <String[]>] [-Exclude <String[]>] [-Before <DateTime>] [-After <DateTime>] [<CommonParameters>]

Description

The Get-Migration function returns Rivet.Migration objects for all the migrations in all or specific databases. With no parameters, looks in the current directory for a rivet.json file and returns all the migrations for all the databases based on that configuration. Use the ConfigFilePath to load and use a specific rivet.json file.

You can return migrations from specific databases by passing those database names as values to the Database parameter.

The Environment parameter is used to load the correct environment-specific settings from the rivet.json file.

You can filter what migrations are returned using the Include or Exclude parameters, which support wildcards, and will match any part of the migration's filename, including the ID.

Use the Before and After parameters to return migrations whose timestamps/IDs come before and after the given dates.

Parameters

Name Type Description Required? Pipeline Input Default Value
Database String[]

The database whose migrations to get.np

false false
Environment String

The environment settings to use.

false false
ConfigFilePath String

The path to the rivet.json file to use. Defaults to rivet.json in the current directory.

false false
Include String[]

A list of migrations to include. Matches against the migration's ID or Name or the migration's file name (without extension). Wildcards permitted.

false false
Exclude String[]

A list of migrations to exclude. Matches against the migration's ID or Name or the migration's file name (without extension). Wildcards permitted.

false false
Before DateTime

Only get migrations before this date. Default is all.

false false
After DateTime

Only get migrations after this date. Default is all.

false false

Return Values

Rivet.Migration.

EXAMPLE 1

Get-Migration

Returns Rivet.Migration objects for each migration in each database.

EXAMPLE 2

Get-Migration -Database StarWars

Returns Rivet.Migration objects for each migration in the StarWars database.

EXAMPLE 3

Get-Migration -Include 'CreateDeathStarTable','20150101000648','20150101150448_CreateRebelBaseTable','*Hoth*','20150707*'

Demonstrates how to get use the Include parameter to find migrations by name, ID, or file name. In this case, the following migrations will be returned:

EXAMPLE 4

Get-Migration -Exclude 'CreateDeathStarTable','20150101000648','20150101150448_CreateRebelBaseTable','*Hoth*','20150707*'

Demonstrates how to get use the Exclude parameter to skip/not return certain migrations by name, ID, or file name. In this case, the following migrations will be not be returned: