CreateSequence creates a new sequence.
(ctx context.Context, seq *Sequence)
| 139 | |
| 140 | // CreateSequence creates a new sequence. |
| 141 | func (pgs *Collection) CreateSequence(ctx context.Context, seq *Sequence) error { |
| 142 | // Ensure that the sequence does not already exist |
| 143 | if _, ok := pgs.accessedMap[seq.Id]; ok { |
| 144 | return errors.Errorf(`relation "%s" already exists`, seq.Id.SequenceName()) |
| 145 | } |
| 146 | if ok, err := pgs.underlyingMap.Has(ctx, string(seq.Id)); err != nil { |
| 147 | return err |
| 148 | } else if ok { |
| 149 | return errors.Errorf(`relation "%s" already exists`, seq.Id.SequenceName()) |
| 150 | } |
| 151 | // Add it to our cache, which will be emptied when we do anything permanent |
| 152 | pgs.accessedMap[seq.Id] = seq |
| 153 | return nil |
| 154 | } |
| 155 | |
| 156 | // DropSequence drops existing sequences. |
| 157 | func (pgs *Collection) DropSequence(ctx context.Context, names ...id.Sequence) (err error) { |
no test coverage detected