コード例 #1
0
        /// <inheritdoc />
        public virtual void MigrationMetadataChanged(IMigrationMetadata migrationMetadata, IExtendedMigrationProcessor extendedMigrationProcessor)
        {
            Processor = extendedMigrationProcessor;

            if (!Enabled)
            {
                return;
            }

            if (!Processor.SchemaExists(CommonSchemaName) ||
                !Processor.SchemaExists(AuthCodeSchemaName))
            {
                return;
            }

            var logonSql = MigrationConfig
                           .PrepareSql(SqlResources.LogonScriptSql)
                           .ReplaceIgnoreCase("{CommonSchemaName}", CommonSchemaName)
                           .ReplaceIgnoreCase("{AuthCodeSchemaName}", AuthCodeSchemaName);

            Execute(logonSql);

            if (Processor.SchemaExists(MigrationConfig.Schema))
            {
                ProcessAfter(new CreateSchemaWithPrefixExpression
                {
                    SchemaName           = MigrationConfig.Schema,
                    SchemaPrefixId       = MigrationConfig.GetSchemaPrefixId(),
                    SchemaPrefixUniqueId = MigrationConfig.GetSchemaPrefixUniqueId()
                });
            }
        }
コード例 #2
0
        /// <summary>
        /// Will be called just after the Schema is created<br/>
        /// Can be used to execute custom grants or other database operations.
        /// </summary>
        /// <param name="expression"></param>
        public virtual void ProcessAfter(ICreateSchemaWithPrefixExpression expression)
        {
            if (!Enabled)
            {
                return;
            }

            if (!Processor.SchemaExists(CommonSchemaName))
            {
                return;
            }

            Logger.LogInformation($"ProcessAfter Schema:{expression.SchemaName} SchemaPrefix:{expression.SchemaPrefixId}");

            var sqlAll = MigrationConfig
                         .PrepareSql(SqlResources.SchemaPrefixSql)
                         .ReplaceIgnoreCase("{CommonSchemaName}", CommonSchemaName)
                         .ReplaceIgnoreCase("{AuthCodeSchemaName}", AuthCodeSchemaName);


            Execute(sqlAll);
        }