-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Convert deleted flag to timestamp
- Loading branch information
Showing
15 changed files
with
255 additions
and
24 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
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
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
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
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
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
136 changes: 136 additions & 0 deletions
136
CleanArchitecture.Infrastructure/Migrations/20241208214605_AddDeletedTimestamp.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
CleanArchitecture.Infrastructure/Migrations/20241208214605_AddDeletedTimestamp.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,95 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace CleanArchitecture.Infrastructure.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class AddDeletedTimestamp : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.AddColumn<DateTimeOffset>( | ||
name: "DeletedAt", | ||
table: "Users", | ||
type: "datetimeoffset", | ||
nullable: true); | ||
|
||
migrationBuilder.AddColumn<DateTimeOffset>( | ||
name: "DeletedAt", | ||
table: "Tenants", | ||
type: "datetimeoffset", | ||
nullable: true); | ||
|
||
migrationBuilder.Sql("UPDATE Users SET DeletedAt = SYSDATETIMEOFFSET() WHERE Deleted = 1"); | ||
migrationBuilder.Sql("UPDATE Tenants SET DeletedAt = SYSDATETIMEOFFSET() WHERE Deleted = 1"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "Deleted", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "Deleted", | ||
table: "Tenants"); | ||
|
||
migrationBuilder.UpdateData( | ||
table: "Tenants", | ||
keyColumn: "Id", | ||
keyValue: new Guid("b542bf25-134c-47a2-a0df-84ed14d03c4a"), | ||
column: "DeletedAt", | ||
value: null); | ||
|
||
migrationBuilder.UpdateData( | ||
table: "Users", | ||
keyColumn: "Id", | ||
keyValue: new Guid("7e3892c0-9374-49fa-a3fd-53db637a40ae"), | ||
column: "DeletedAt", | ||
value: null); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.AddColumn<bool>( | ||
name: "Deleted", | ||
table: "Users", | ||
type: "bit", | ||
nullable: false, | ||
defaultValue: false); | ||
|
||
migrationBuilder.AddColumn<bool>( | ||
name: "Deleted", | ||
table: "Tenants", | ||
type: "bit", | ||
nullable: false, | ||
defaultValue: false); | ||
|
||
migrationBuilder.Sql("UPDATE Users SET Deleted = true WHERE DeletedAt IS NOT NULL"); | ||
migrationBuilder.Sql("UPDATE Tenants SET Deleted = true WHERE DeletedAt IS NOT NULL"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "DeletedAt", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "DeletedAt", | ||
table: "Tenants"); | ||
|
||
migrationBuilder.UpdateData( | ||
table: "Tenants", | ||
keyColumn: "Id", | ||
keyValue: new Guid("b542bf25-134c-47a2-a0df-84ed14d03c4a"), | ||
column: "Deleted", | ||
value: false); | ||
|
||
migrationBuilder.UpdateData( | ||
table: "Users", | ||
keyColumn: "Id", | ||
keyValue: new Guid("7e3892c0-9374-49fa-a3fd-53db637a40ae"), | ||
column: "Deleted", | ||
value: false); | ||
} | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.