mirror of
https://github.com/bitwarden/server.git
synced 2025-02-16 01:51:21 +01:00
Fix run_migrations.sh script (#2289)
This commit is contained in:
parent
893c4fbf6c
commit
b828faf30d
@ -33,22 +33,30 @@ BEGIN
|
|||||||
CREATE DATABASE $DATABASE;
|
CREATE DATABASE $DATABASE;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
GO
|
||||||
IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'migrations_$DATABASE')
|
IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'migrations_$DATABASE')
|
||||||
BEGIN
|
BEGIN
|
||||||
CREATE DATABASE migrations_$DATABASE;
|
CREATE DATABASE migrations_$DATABASE;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
GO
|
GO
|
||||||
IF OBJECT_ID('[migrations_$DATABASE].[dbo].[migrations]') IS NULL
|
"
|
||||||
|
/opt/mssql-tools/bin/sqlcmd -S $SERVER -d master -U $USER -P $PASSWD -I -Q "$QUERY"
|
||||||
|
echo "Return code: $?"
|
||||||
|
|
||||||
|
# Create migrations table if it does not already exist
|
||||||
|
QUERY="IF OBJECT_ID('[migrations_$DATABASE].[dbo].[migrations]') IS NULL
|
||||||
BEGIN
|
BEGIN
|
||||||
CREATE TABLE [migrations_$DATABASE].[dbo].[migrations] (
|
CREATE TABLE [migrations_$DATABASE].[dbo].[migrations] (
|
||||||
[Id] INT IDENTITY(1,1) PRIMARY KEY,
|
[Id] INT IDENTITY(1,1) PRIMARY KEY,
|
||||||
[Filename] NVARCHAR(MAX) NOT NULL,
|
[Filename] NVARCHAR(MAX) NOT NULL,
|
||||||
[CreationDate] DATETIME2 (7) NULL,
|
[CreationDate] DATETIME2 (7) NULL,
|
||||||
);
|
);
|
||||||
END;"
|
END;
|
||||||
|
GO
|
||||||
/opt/mssql-tools/bin/sqlcmd -S $SERVER -d master -U $USER -P $PASSWD -I -Q "$QUERY"
|
"
|
||||||
|
/opt/mssql-tools/bin/sqlcmd -S $SERVER -d migrations_$DATABASE -U $USER -P $PASSWD -I -Q "$QUERY"
|
||||||
|
echo "Return code: $?"
|
||||||
|
|
||||||
should_migrate () {
|
should_migrate () {
|
||||||
local file=$(basename $1)
|
local file=$(basename $1)
|
||||||
|
Loading…
Reference in New Issue
Block a user