Skip to content

Ordering created definitions #11

@simonpinn

Description

@simonpinn

If the definitions were ordered by dependency then it would be possible to run the definition scripts using a DbUp upgrader against a blank database. This would be great for creating a new database from the schema definition without the need for a initialisation script, especially if the definitions have been generated from an existing database.

As a basic example, it'd be great to be able to do the following:

...
            var scripts = Directory.GetFiles("../../Definitions", "*.sql", SearchOption.AllDirectories)
                    .Select(x => new SqlScript(Path.GetFileName(x), File.ReadAllText(x).Replace("SET ANSI_NULLS ON", string.Empty).Replace("SET QUOTED_IDENTIFIER ON", string.Empty)));

            var initial = DeployChanges.To
                    .SqlDatabase(connectionString)
                    .WithScripts(scripts)
                    .LogToConsole()
                    .Build();

            var initResult = initial.PerformUpgrade();
...

However due to dependencies (foreign keys for example), the scripts need to be executed in order, this could be done at the time of creating the definition scripts.

Has this been considered? Great libray btw.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions