Skip to content
Snippets Groups Projects
Select Git revision
  • Product/704-basicReporting
  • master default protected
  • gitkeep
  • Issue/2446-responsibleOrganizations
  • dev protected
  • Issue/2309-docs
  • Issue/2355-topLevelOrg
  • Issue/2412-gitlabDuplicatesinProjectQuotas
  • Issue/2287-guestRole
  • Issue/2364-testingKpiParser
  • Issue/2102-gitLabResTypeRCV
  • Issue/2278-gitlabToS
  • Issue/2284-dbLogIndex
  • Issue/5678-addingGuestRoleToRoles
  • Issue/2265-UpdatingS3EndpointUDE
  • Issue/XXXX-testingMigrationsTimestamp
  • Issue/2101-gitLabResTypeUi
  • Issue/1788-extractionCronjob
  • Issue/2222-resourceDateCreated
  • Issue/2221-projectDateCreated
  • Issue/1321-pidEnquiryOverhaul
  • v2.20.1
  • v2.20.0
  • v2.19.0
  • v2.18.0
  • v2.17.0
  • v2.16.0
  • v2.15.0
  • v2.14.0
  • v2.13.0
  • v2.12.0
  • v2.11.0
  • v2.10.0
  • v2.9.0
  • v2.8.0
  • v2.7.0
  • v2.6.0
  • v2.5.0
  • v2.4.0
  • v2.3.0
  • v2.2.1
41 results

migrations

  • Open with
  • Download source code
  • Your workspaces

      A workspace is a virtual sandbox environment for your code in GitLab.

      No agents available to create workspaces. Please consult Workspaces documentation for troubleshooting.

  • Marcel Nellesen's avatar
    Marcel Nellesen authored
    Topic/1051 basic reporting
    
    See merge request coscine/cs/migrations!32
    952bd89e
    History

    Migrator and Migrations

    This project provides a library with the migrations based on Fluent Migrator and an executable to start the migrations.

    The library (Migrations) can also be migrated by the official Fluent Migrator runner.

    Our custom executable (Coscine.Migrator.exe) also allows for the creation of the needed database.

    Start a migration by calling Coscine.Migrator.exe --migrate_up. This will create the needed database and run all migrations. You can run the command again at a later time, to install additional migrations. Migrations already deployed will not be deployed again.

    You can revert a migration by calling Coscine.Migrator.exe --roll_back 1. This will remove the most recent migration. Replacing the 1 with a 2 will revert the two most recent migrations and so on.

    The executable will create a connection string based on the Consul values:

    • DbDataSourceKey: coscine/global/db_data_source
    • DbNameKey: coscine/global/db_name
    • DbUserIdKey: coscine/global/db_user_id
    • DbPasswordKey: coscine/global/db_password

    You can call the migrations from a diffrent project. The connection string information from Consul (except db_name) will be used. Use the CoscineMigrations class for this:

    // Setup the migrator class
    var targetAssembly = typeof(CoscineMigrations).Assembly;
    var migrator = new CoscineMigrations();
    var dbDatabase = "YOUR_DATABASE_NAME_HERE";
    migrator.SetServiceProvider(targetAssembly, migrator.GetDatabaseConnectionStringFromConsul(dbDatabase));
    
    // Create the database if needed
    migrator.EnsureDatabase(dbDatabase);
    // Run the migrations on the database
    migrator.MigrateUp();