/// <summary>
 /// Outputs statements for altering of new sequences.
 /// </summary>
 /// <param name="writer">Writer the output should be written to.</param>
 /// <param name="oldSchema">The old schema.</param>
 /// <param name="newSchema">The new schema.</param>
 /// <param name="searchPathHelper">The search path helper.</param>
 public static void AlterCreatedSequences(StreamWriter writer, [NullGuard.AllowNull] PgSchema oldSchema, PgSchema newSchema, SearchPathHelper searchPathHelper)
 {
     // Alter created sequences
     foreach (PgSequence sequence in newSchema.Sequences)
     {
         if ((oldSchema == null || !oldSchema.ContainsSequence(sequence.Name)) && sequence.Owner != null && sequence.Owner != string.Empty)
         {
             searchPathHelper.OutputSearchPath(writer);
             writer.WriteLine();
             writer.WriteLine(sequence.OwnedBySQL);
         }
     }
 }
 /// <summary>
 /// Outputs statements for creation of new sequences.
 /// </summary>
 /// <param name="writer">Writer the output should be written to.</param>
 /// <param name="oldSchema">Original schema.</param>
 /// <param name="newSchema">New schema.</param>
 /// <param name="searchPathHelper">Search path helper.</param>
 public static void Create(StreamWriter writer, [NullGuard.AllowNull] PgSchema oldSchema, PgSchema newSchema, SearchPathHelper searchPathHelper)
 {
     // Add new sequences
     foreach (PgSequence sequence in newSchema.Sequences)
     {
         if (oldSchema == null || !oldSchema.ContainsSequence(sequence.Name))
         {
             searchPathHelper.OutputSearchPath(writer);
             writer.WriteLine();
             writer.WriteLine(sequence.CreationSQL);
         }
     }
 }
Exemple #3
0
 public static void AlterCreatedSequences(TextWriter writer, PgSchema oldSchema, PgSchema newSchema, SearchPathHelper searchPathHelper)
 {
     // Alter created sequences
     foreach (var sequence in newSchema.GetSequences())
     {
         if ((oldSchema == null || !oldSchema.ContainsSequence(sequence.Name)) && !string.IsNullOrEmpty(sequence.OwnedBy))
         {
             searchPathHelper.OutputSearchPath(writer);
             writer.WriteLine();
             writer.WriteLine(sequence.GetOwnedBySql());
         }
     }
 }
Exemple #4
0
 public static void CreateSequences(TextWriter writer, PgSchema oldSchema, PgSchema newSchema, SearchPathHelper searchPathHelper)
 {
     // Add new sequences
     foreach (var sequence in newSchema.GetSequences())
     {
         if (oldSchema == null || !oldSchema.ContainsSequence(sequence.Name))
         {
             searchPathHelper.OutputSearchPath(writer);
             writer.WriteLine();
             writer.WriteLine(sequence.GetCreationSql());
         }
     }
 }
        /// <summary>
        /// Outputs statements for dropping of sequences that do not exist anymore.
        /// </summary>
        public static void Drop(StreamWriter writer, [NullGuard.AllowNull] PgSchema oldSchema, PgSchema newSchema, SearchPathHelper searchPathHelper)
        {
            if (oldSchema == null)
            {
                return;
            }

            // Drop sequences that do not exist in new schema
            foreach (PgSequence sequence in oldSchema.Sequences)
            {
                if (!newSchema.ContainsSequence(sequence.Name))
                {
                    searchPathHelper.OutputSearchPath(writer);
                    writer.WriteLine();
                    writer.WriteLine(sequence.DropSQL);
                }
            }
        }
Exemple #6
0
        public static void DropSequences(TextWriter writer, PgSchema oldSchema, PgSchema newSchema, SearchPathHelper searchPathHelper)
        {
            if (oldSchema == null)
            {
                return;
            }

            // Drop sequences that do not exist in new schema
            foreach (var sequence in oldSchema.GetSequences())
            {
                if (!newSchema.ContainsSequence(sequence.Name))
                {
                    searchPathHelper.OutputSearchPath(writer);
                    writer.WriteLine();
                    writer.WriteLine(sequence.GetDropSql());
                }
            }
        }