-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If not specified, the Name, Email, and Comment fields should always b…
…e NULL instead of an empty string + updated UpdateEntry method to set values as null if empty or whitespace + added migration to fix existing values in the database
- Loading branch information
Showing
3 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/Skybrud.Umbraco.Feedback/Migrations/FixEmptyStringValuesMigration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Skybrud.Umbraco.Feedback.Constants; | ||
using Umbraco.Core.Logging; | ||
using Umbraco.Core.Migrations; | ||
|
||
namespace Skybrud.Umbraco.Feedback.Migrations { | ||
|
||
public class FixEmptyStringValuesMigration : MigrationBase { | ||
|
||
public FixEmptyStringValuesMigration(IMigrationContext context) : base(context) { } | ||
|
||
public override void Migrate() { | ||
|
||
if (!TableExists(FeedbackConstants.TableName)) return; | ||
|
||
int affected1 = Context.Database.Execute("UPDATE [SkybrudFeedback] SET [Name] = null WHERE [Name] LIKE '';"); | ||
int affected2 = Context.Database.Execute("UPDATE [SkybrudFeedback] SET [Email] = null WHERE [Email] LIKE '';"); | ||
int affected3 = Context.Database.Execute("UPDATE [SkybrudFeedback] SET [Comment] = null WHERE [Comment] LIKE '';"); | ||
|
||
Logger.Info<FixEmptyStringValuesMigration>($"Fixed empty string values for name column in {affected1} rows."); | ||
Logger.Info<FixEmptyStringValuesMigration>($"Fixed empty string values for email column in {affected2} rows."); | ||
Logger.Info<FixEmptyStringValuesMigration>($"Fixed empty string values for comment column in {affected3} rows."); | ||
|
||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters