Exemple #1
0
        static void CreateRevisionLogTable()
        {
            SqlStatement.Execute(@"
              IF NOT EXISTS(SELECT * FROM sys.objects 
                WHERE object_id = OBJECT_ID(N'[dbo].[RevisionLog]') AND type in (N'U')) BEGIN
                CREATE TABLE RevisionLog ( 
	              id      int identity(1,1)  NOT NULL,
	              name    varchar(255) NOT NULL,
	              created datetime NOT NULL DEFAULT (GETDATE()));
                ALTER TABLE RevisionLog ADD CONSTRAINT UQ_RevisionLog_name UNIQUE (name);
                ALTER TABLE RevisionLog ADD CONSTRAINT PK_RevisionLog PRIMARY KEY CLUSTERED (id);
             END");
        }
Exemple #2
0
        public void Execute()
        {
            if (RevisionLog.ContainsRevision(this))
            {
                Log.v("DB", $"Skipping upgrade script \'{Name}\' as it is already in database.");
                return;
            }

            Log.i("DB", $"Upgrading with script \'{Name}\'");
            using (var transaction = new TransactionScope())
            {
                foreach (string batch in GetBatches())
                {
                    SqlStatement.Execute(batch);
                }
                RevisionLog.Add(this);
                transaction.Complete();
            }
        }