Skip to content

Commit

Permalink
Small example for scripts and the new constraint attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
fubar-coder committed Apr 16, 2019
1 parent 0f589e4 commit cdaf985
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
45 changes: 45 additions & 0 deletions samples/FluentMigrator.Example.Migrations/3_UpdateNotesByScript.cs
@@ -0,0 +1,45 @@
#region License
// Copyright (c) 2019, FluentMigrator Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

using FluentMigrator.Runner.Constraints;

namespace FluentMigrator.Example.Migrations
{
/// <summary>
/// Update notes.
/// </summary>
/// <remarks>
/// This is only run when the migration 20090906205440 was already applied to the database.
/// </remarks>
[Migration(20190416112000)]
[CurrentVersionMigrationConstraint(20090906205440)]
public class UpdateNotesByScript : Migration
{
/// <inheritdoc />
public override void Up()
{
Execute.Sql(@"/* this is a test script */
update Notes set body=body || ' (modified)';
");
}

/// <inheritdoc />
public override void Down()
{
// Nothing to do here
}
}
}
Expand Up @@ -11,6 +11,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\FluentMigrator\FluentMigrator.csproj" />
<ProjectReference Include="..\..\src\FluentMigrator.Runner\FluentMigrator.Runner.csproj" />
</ItemGroup>
<!-- Automatically include all *.sql files as embedded resources
for use with Migration.Execute.EmbeddedScript(string EmbeddedSqlScriptName) -->
Expand Down

0 comments on commit cdaf985

Please sign in to comment.