netmash/infrastructure/NDB.Infrastructure.Database.../Scripts/SqlServer/02.MigrationTables.sql

30 lines
1.2 KiB
MySQL
Raw Normal View History

if not exists (select top 1 1 from sys.objects where name = 'MigrationSignature' and type = 'U' and SCHEMA_NAME(schema_id) = 'migration')
begin
create table migration.MigrationSignature
(
Id int identity(1, 1) constraint PK_MigrationSignature primary key,
MigrationDate Datetime not null,
MachineName varchar(30) not null,
LastVersion varchar(20) not null
)
end
if not exists (select top 1 1 from sys.objects where name = 'MigratedVersion' and type = 'U' and SCHEMA_NAME(schema_id) = 'migration')
begin
create table migration.MigratedVersion
(
Id int identity(1, 1) constraint PK_MigratedVersion primary key,
SignatureId int constraint FK_MigratedVersion_MigrationSignature foreign key references migration.MigrationSignature(Id),
[Version] varchar(20) not null
)
end
if not exists (select top 1 1 from sys.objects where name = 'MigratedScript' and type = 'U' and SCHEMA_NAME(schema_id) = 'migration')
begin
create table migration.MigratedScript
(
Id int identity(1, 1) constraint PK_MigratedScript primary key,
VersionId int constraint FK_MigratedScript_MigratedVersion foreign key references migration.MigratedVersion(Id),
Script varchar(250) not null
)
end