Skip to content

feat: [#669] Migration support GENERATED#1044

Merged
almas-x merged 4 commits intomasterfrom
almas/#669
May 23, 2025
Merged

feat: [#669] Migration support GENERATED#1044
almas-x merged 4 commits intomasterfrom
almas/#669

Conversation

@almas-x
Copy link
Contributor

@almas-x almas-x commented May 21, 2025

📑 Description

Closes goravel/goravel#669

schema.Create("postgres_generated_as", func(table contractsschema.Blueprint) {
		table.ID()
		table.String("name")
		table.Integer("small_integer").GeneratedAs()
		table.BigInteger("integer").GeneratedAs("START WITH 10 INCREMENT BY 2")
		table.SmallInteger("big_integer").GeneratedAs("START WITH 20 INCREMENT BY 5").Always()

	})

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings May 21, 2025 02:01
@almas-x almas-x requested a review from a team as a code owner May 21, 2025 02:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces migration support for generated columns while also adding support for the "Always" attribute in column definitions.

  • Added Always() and GeneratedAs() methods (and their corresponding getters) in both production and mock implementations.
  • Updated table command display logic and test cases to incorporate schema prefixes for table names.
  • Updated interface definitions in the contracts package to support the new methods.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
mocks/database/driver/ColumnDefinition.go Added mock implementations for Always, GeneratedAs, GetGeneratedAs, IsAlways, and IsSetGeneratedAs.
database/schema/column.go Implemented Always and GeneratedAs methods in ColumnDefinition, and added GetGeneratedAs and IsAlways logic.
database/console/table_command_test.go Updated expected output to include schema prefix for table names.
database/console/table_command.go Modified display logic to prepend schema to the table name if available.
contracts/database/driver/column.go Updated the ColumnDefinition interface to include new methods and refined comments.
Comments suppressed due to low confidence (1)

database/schema/column.go:81

  • Appending an empty string to the expression slice may be unnecessary and could lead to confusion when handling variadic arguments. Consider revising the logic to either accept a single expression or document the rationale for always appending an empty string.
expression = append(expression, "")

@codecov
Copy link

codecov bot commented May 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.48%. Comparing base (855e8a8) to head (92d4fdc).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1044   +/-   ##
=======================================
  Coverage   70.48%   70.48%           
=======================================
  Files         176      176           
  Lines       12339    12339           
=======================================
  Hits         8697     8697           
  Misses       3261     3261           
  Partials      381      381           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@almas-x
Copy link
Contributor Author

almas-x commented May 21, 2025

I will create a new PR to add external tests after goravel/postgres is updated.

@almas-x almas-x changed the title chore: [#669] Migration support GENERATED feat: [#669] Migration support GENERATED May 21, 2025
hwbrzzl
hwbrzzl previously approved these changes May 21, 2025
Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

Co-authored-by: Wenbo Han <hwbrzzl@gmail.com>
almas-x and others added 2 commits May 21, 2025 16:08
Co-authored-by: Wenbo Han <hwbrzzl@gmail.com>
Co-authored-by: Wenbo Han <hwbrzzl@gmail.com>
@almas-x almas-x requested a review from hwbrzzl May 21, 2025 08:34
@almas-x almas-x enabled auto-merge (squash) May 21, 2025 09:41
@almas-x almas-x disabled auto-merge May 22, 2025 23:27
@almas-x almas-x requested review from hwbrzzl and removed request for hwbrzzl May 22, 2025 23:27
@almas-x almas-x merged commit 88c15e8 into master May 23, 2025
14 checks passed
@almas-x almas-x deleted the almas/#669 branch May 23, 2025 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migration support GENERATED

3 participants