You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_, err=m.session.SQL().Exec("create table if not exists schema_history(schema_version int not null)")
48
+
_, err=m.session.SQL().Exec("create table if not exists schema_history(schema_version int not null, primary key(schema_version))")
49
+
iferr!=nil {
50
+
returnerr
51
+
}
52
+
53
+
// Ensure the schema_history table has a primary key, creating it if necessary
54
+
// This logic is implemented separately from regular migrations to improve compatibility with databases running in strict or HA modes
55
+
dbIdentifierColumn:="table_schema"
56
+
ifdbType==Postgres {
57
+
dbIdentifierColumn="table_catalog"
58
+
}
59
+
rows, err:=m.session.SQL().Query(
60
+
"select 1 from information_schema.table_constraints where constraint_type = 'PRIMARY KEY' and table_name = 'schema_history' and "+dbIdentifierColumn+" = ?",
0 commit comments