rophuine / nschemer Goto Github PK
View Code? Open in Web Editor NEW.Net-based database schema management
License: GNU Lesser General Public License v3.0
.Net-based database schema management
License: GNU Lesser General Public License v3.0
To reproduce:
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.
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:
sourceAssembly
is passed as null
; andsourceAssembly
parameter, or provide Assembly.GetCallingAssembly()
as the default for sourceAssembly
.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?
If you script is something like:
-- do something
GO
-- do something else
GO[eof]
The script fails. The parser trying to split the script is searching for "\nGO\n" which obviously doesn't match when there is no newline at the end of the file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.