Merge pull request 'docker' (#17) from testbranch into main
Reviewed-on: #17
This commit was merged in pull request #17.
This commit is contained in:
+1
-1
@@ -30,7 +30,7 @@ services:
|
||||
- EnableHttpsRedirect=false
|
||||
- TenantSettings__BaseDomain=timetracker.marc-wieland.de
|
||||
volumes:
|
||||
- dpkeys:/root/.aspnet/DataProtection-Keys
|
||||
- dpkeys:/home/app/.aspnet/DataProtection-Keys
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
|
||||
@@ -227,10 +227,54 @@ using (var scope = app.Services.CreateScope())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if column IsApproved in Tenants table is of type integer
|
||||
using (var cmdCheckApproved = conn.CreateCommand())
|
||||
{
|
||||
cmdCheckApproved.CommandText = @"
|
||||
SELECT data_type
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'Tenants' AND column_name = 'IsApproved';";
|
||||
var dataType = await cmdCheckApproved.ExecuteScalarAsync() as string;
|
||||
if (dataType != null && dataType.Equals("integer", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Alter the column type to boolean
|
||||
using (var cmdAlterApproved = conn.CreateCommand())
|
||||
{
|
||||
cmdAlterApproved.CommandText = @"
|
||||
ALTER TABLE ""Tenants""
|
||||
ALTER COLUMN ""IsApproved"" TYPE boolean
|
||||
USING (""IsApproved"" <> 0);";
|
||||
await cmdAlterApproved.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if column CreatedAt in Tenants table is of type text or character varying
|
||||
using (var cmdCheckCreatedAt = conn.CreateCommand())
|
||||
{
|
||||
cmdCheckCreatedAt.CommandText = @"
|
||||
SELECT data_type
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'Tenants' AND column_name = 'CreatedAt';";
|
||||
var dataType = await cmdCheckCreatedAt.ExecuteScalarAsync() as string;
|
||||
if (dataType != null && (dataType.Equals("text", StringComparison.OrdinalIgnoreCase) || dataType.Equals("character varying", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
// Alter the column type to timestamp without time zone
|
||||
using (var cmdAlterCreatedAt = conn.CreateCommand())
|
||||
{
|
||||
cmdAlterCreatedAt.CommandText = @"
|
||||
ALTER TABLE ""Tenants""
|
||||
ALTER COLUMN ""CreatedAt"" TYPE timestamp without time zone
|
||||
USING (""CreatedAt""::timestamp without time zone);";
|
||||
await cmdAlterCreatedAt.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Fehler beim Konvertieren der IsTenantAdmin-Spalte in PostgreSQL: {ex.Message}");
|
||||
Console.WriteLine($"Fehler beim Konvertieren der PostgreSQL-Spaltentypen (IsTenantAdmin/IsApproved/CreatedAt): {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user