Documentation
¶
Overview ¶
Copyright © 2025 Roy Sowers <inskribe@inskribestudio.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2025 Roy Sowers <inskribe@inskribestudio.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2025 Roy Sowers <inskribe@inskribestudio.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2025 Roy Sowers <inskribe@inskribestudio.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2025 Roy Sowers <inskribe@inskribestudio.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2025 Roy Sowers <inskribe@inskribestudio.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAppliedDeltas ¶ added in v0.3.0
GetAppliedDeltas retrieves applied deltas from the schemer table. Queries the database for all applied delta tags and returns them as a map.
Params:
- connection: pointer to a pgx.Conn representing the database connection
- ctx: context for controlling query timeout or cancellation
Returns:
- map[int]bool: a map of applied delta tags where the key is the tag version and value is true
- error: non-nil if the schemer table is missing or a query/scan error occurs
func IsNoOpSql ¶
IsNoOpSql returns true if the SQL string contains no executable statements. Ignores empty lines, line comments (--), and block comments (/* */).
Params:
- data: the SQL content to evaluate
Returns:
- bool: true if the SQL contains only comments or whitespace; false otherwise
func PruneNoOp ¶
PruneNoOp removes no-op SQL deltas from the provided map in-place. Uses concurrent workers to scan for and discard deltas that contain only comments or whitespace.
Params:
- data: pointer to a map of delta tags to raw SQL bytes; will be mutated directly
func PruneNoOpUp ¶
PruneNoOpUp removes no-op SQL deltas from the provided map in-place for upDelta. Uses concurrent workers to scan for and discard deltas that contain only comments or whitespace.
Params:
- data: pointer to a map of delta tags to raw SQL bytes; will be mutated directly
Types ¶
type CommandArgs ¶ added in v0.3.0
type CommandArgs struct {
PruneNoOp bool // if true, skips deltas that are no-ops
// contains filtered or unexported fields
}
CommandArgs holds parsed CLI arguments for a migration command. Note: the meaning of toTag and fromTag depends on the command type:
- For "up": fromTag is the lower bound, toTag is the upper bound.
- For "down": fromTag is the upper bound, toTag is the lower bound.
func (CommandArgs) GetRequestedDeltas ¶ added in v0.3.0
func (args CommandArgs) GetRequestedDeltas() (*DeltaRequest, error)
GetRequestedDeltas parses the user's migration flags into a DeltaRequest. Converts --from, --to, and --cherry-pick CLI inputs into a structured request.
Returns:
- *deltaRequest: the constructed delta request with range or specific tags
- error: non-nil if any tag is not a valid integer
type DeltaRequest ¶ added in v0.3.0
type DeltaRequest struct {
To *int // tag boundary (upper for up, lower for down)
From *int // tag boundary (lower for up, upper for down)
Cherries *map[int]bool // specific delta tags to apply; overrides From/To if set
LastTag *int // indicates that only the last delta should be applied
}
DeltaRequest defines the range or specific set of deltas to apply.
For an "up" command:
- From is the lower bound (inclusive)
- To is the upper bound (inclusive)
For a "down" command:
- From is the upper bound (inclusive)
- To is the lower bound (inclusive)
If Cherries is set, it overrides From/To and applies only the specified tags.
type PostDelta ¶ added in v0.3.0
type PostDelta struct {
Tag int // unique identifier of the delta
Data []byte // raw SQL content of the post delta
PostStatus PostStatusEnum // current post status (e.g., Pending, Applied)
}
PostDelta represents a post-migration delta and its metadata.
type PostForce ¶ added in v0.3.0
type PostForce struct {
Force bool // allow applying post deltas even if not registered in schemer
}
Represents user input for post command.
type PostStatusEnum ¶ added in v0.3.0
type PostStatusEnum int
PostStatusEnum represents the state of a post delta.
Possible values:
- 0: NoExist (no associated post delta)
- 1: Pending (post delta exists but hasn't been applied)
- 2: Applied (post delta has been executed)
const ( NoExist PostStatusEnum = iota // no associated post delta Pending // post delta exists but has not been applied Applied // post delta has been successfully applied )
func (PostStatusEnum) String ¶ added in v0.3.0
func (i PostStatusEnum) String() string
type UpDelta ¶ added in v0.3.0
type UpDelta struct {
Tag int // unique identifier of the delta
Data []byte // raw SQL content of the up delta
PostStatus PostStatusEnum // post delta status (e.g., NoExist, Pending)
}
UpDelta represents a forward (up) delta and its metadata.