Giter Club home page Giter Club logo

nschemer's People

Contributors

gerrod avatar rophuine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nschemer's Issues

'set nocount on' prevents versionnumber from being updated.

If a script has 'set nocount on' and doesn't revert it the sql to update the nschemer_version table with an updated version number returns false and the whole transition fails.

It might be worth programming defensively against this, by ensuring nocount is off.

image

NSchemer gets into an endless loop

To reproduce:

  • Upgrade a database to Version 2
  • Add an upgrade script for Version 1
  • Try to run NSchemer

NSchemer tries to be clever (by ignoring the version 1 script since its lower than Version 2):

// From: SqlClientDatabase.Update()
foreach (ITransition v in Versions)
{
    if (!AllVersions.Contains(v.VersionNumber) && v.VersionNumber < DatabaseVersion)
        missingUpdates.Add(v);
}

However, the IsCurrent() check reports false since the Version 1 script hasn't been applied. So, the loop:

while (!IsCurrent() && appliedUpdate)

Never exits, since appliedUpdate never gets changed.

Default assembly for SqlScriptTransition doesn't make sense

SqlScriptTransition provides a constructor that does not require an assembly to be passed. This constructor overloads the constructor that does require an assembly, by passing null as the sourceAssembly argument:

public SqlScriptTransition(double versionNumber, string name, string description, string embeddedResourceName) 
    : this(versionNumber, name, description, null, embeddedResourceName) { }

public SqlScriptTransition(double versionNumber, string name, string description, Assembly sourceAssembly,
    string embeddedResourceName)
{
    SourceAssembly = sourceAssembly ?? GetType().Assembly;
    EmbeddedResourceName = embeddedResourceName;
    Description = description;
    Name = name;
    VersionNumber = versionNumber;
}

The default assembly used in this case then resolves to the NSchemer assembly. This is a nonsensical scenario though - it would be difficult to embed a resource into the NSchemer assembly.

Perhaps a more sensible approach would be to:

  • Throw an exception if sourceAssembly is passed as null; and
  • Either remove the constructor which does not have the sourceAssembly parameter, or provide Assembly.GetCallingAssembly() as the default for sourceAssembly.

Default constraint not created when default value is provided

The default value is currently only used when a nullable column is changed to not-null (i.e. when adding a not-null column to an existing table - NSchemer first creates the nullable column, sets all rows to the provided value, and then changes the column to not-null).

What should the API look like here? Should a default constraint always be provided, or are there cases where the developer might want to populate existing rows with a default value without creating a default constraint to populate future rows?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.