Skip to content

Commit

Permalink
[sqlserver] Ensure version table in provided schema
Browse files Browse the repository at this point in the history
Closes #839
  • Loading branch information
alex-kuck committed Dec 25, 2023
1 parent 0815e2d commit 8147693
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions database/sqlserver/sqlserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ func (ss *SQLServer) ensureVersionTable() (err error) {
query := `IF NOT EXISTS
(SELECT *
FROM sysobjects
WHERE id = object_id(N'[dbo].[` + ss.config.MigrationsTable + `]')
WHERE id = object_id(N'[` + ss.config.SchemaName + `].[` + ss.config.MigrationsTable + `]')
AND OBJECTPROPERTY(id, N'IsUserTable') = 1
)
CREATE TABLE ` + ss.config.MigrationsTable + ` ( version BIGINT PRIMARY KEY NOT NULL, dirty BIT NOT NULL );`
CREATE TABLE [` + ss.config.SchemaName + `].[` + ss.config.MigrationsTable + `] ( version BIGINT PRIMARY KEY NOT NULL, dirty BIT NOT NULL );`

if _, err = ss.conn.ExecContext(context.Background(), query); err != nil {
return &database.Error{OrigErr: err, Query: []byte(query)}
Expand Down

0 comments on commit 8147693

Please sign in to comment.