Skip to content

Commit 1499598

Browse files
JaBistDuNarrischJaBistDuNarrisch
authored andcommitted
Throw if default value is DateTime but not UTC
1 parent c6d4d27 commit 1499598

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/Migrator/Framework/Column.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#endregion
1313

14+
using System;
1415
using System.Data;
1516

1617
namespace DotNetProjects.Migrator.Framework;
@@ -20,6 +21,8 @@ namespace DotNetProjects.Migrator.Framework;
2021
/// </summary>
2122
public class Column : IColumn, IDbField
2223
{
24+
private object _defaultValue;
25+
2326
public Column(string name)
2427
{
2528
Name = name;
@@ -159,7 +162,22 @@ public DbType Type
159162

160163
public ColumnProperty ColumnProperty { get; set; }
161164

162-
public object DefaultValue { get; set; }
165+
public object DefaultValue
166+
{
167+
get => _defaultValue;
168+
set
169+
{
170+
if (value is DateTime defaultValueDateTime)
171+
{
172+
if (defaultValueDateTime.Kind != DateTimeKind.Utc)
173+
{
174+
throw new Exception("We only accept UTC values as default DateTime values.");
175+
}
176+
}
177+
178+
_defaultValue = value;
179+
}
180+
}
163181

164182
public bool IsIdentity
165183
{

0 commit comments

Comments
 (0)