mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
@@ -10,30 +10,25 @@ namespace SharpbinV3.Server.Migrations
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
CREATE TRIGGER Users_UID_AutoIncrement
|
||||
AFTER INSERT ON Users
|
||||
BEGIN
|
||||
UPDATE Users
|
||||
SET UID = (
|
||||
SELECT IFNULL(MAX(UID), 0) + 1 FROM Users
|
||||
)
|
||||
WHERE rowid = NEW.rowid AND NEW.UID IS NULL;
|
||||
END;
|
||||
""",
|
||||
suppressTransaction: true
|
||||
);
|
||||
}
|
||||
migrationBuilder.Sql("""
|
||||
CREATE TRIGGER Users_UID_AutoIncrement
|
||||
AFTER INSERT ON Users
|
||||
BEGIN
|
||||
UPDATE Users
|
||||
SET UID = (
|
||||
SELECT IFNULL(MAX(UID), 0) + 1 FROM Users
|
||||
)
|
||||
WHERE rowid = NEW.rowid AND NEW.UID IS NULL;
|
||||
END;
|
||||
""", suppressTransaction: true);
|
||||
|
||||
}
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
DROP TRIGGER IF EXISTS Users_UID_AutoIncrement;
|
||||
"""
|
||||
);
|
||||
migrationBuilder.Sql("""
|
||||
DROP TRIGGER IF EXISTS Users_UID_AutoIncrement;
|
||||
""");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user