Search code examples
c#sql-serverfluent-migrator

c# Fluent Migration Schema


Does anyone know if there is a way to use fluent migrator to create schema prefix tables for different users e.g.

UserMachine1 points to a database but their tables are prefixed with UserMachine1.TableName when they run the migrations.

UserMachine2 points to the same database but would generate UserMachine2.TableName in the same database.

As you can see the schema would be machine name specific in our case.

  1. Can this be done in fluent migrator?
  2. if it can how can you define the schema.VersionInfo table prefix. as out of the box, it just puts it under dbo.VersionInfo like all other tables.

Is this even a good idea? as I am not the inventor of this idea, supposedly due to moving to azure databases.

Many thanks for your thoughts and answers, cheers


Solution

  • I found that there was this link that detailed how you might do this https://fluentmigrator.github.io/articles/version-table-metadata.html still not sure it is a good idea, as then you would also have to rename primary keys and constraints if you do provide nicely named ones. Also how would you run custom SQL scripts to run against specific schema ones. All feels like adding extra work which is not giving much value.