Skip to content

Conversation

@puzzledpolymath
Copy link
Contributor

@puzzledpolymath puzzledpolymath commented Jul 12, 2025

Since the pull request cycle/database#226 has been merged, it might be a good idea to ignore the first and after attributes when equaling the default values? So migrations are not declaring them for every column when not needed.

🔍 What was changed

  • Added logic to ignore the first and after attributes when equaling the default values.
  • Added some test cases (using Reflection) for the Renderer::columnOptions method.

🤔 Why?

When thinking about how column positioning would be used in migrations, I'm of the opinion they would be defined manually. As in I can't imagine defining this for an entity, instead I'd likely generate a migration, say containing an added column and then modify the options to position the new column after and existing column, to suit an order I prefer.

    public function up(): void
    {
        $this->table('api_key')->addColumn('expires_at', 'datetime', [
            'nullable' => true,
            'defaultValue' => null,
            'comment' => 'Date and time API key will expire',
            'after' => 'updated_at',
        ]);
    }

📝 Checklist

  • How was this tested:
    • Unit tests added

@cycle cycle deleted a comment from codecov bot Jul 12, 2025
@codecov
Copy link

codecov bot commented Jul 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.29%. Comparing base (7d977c2) to head (f67926b).
Report is 4 commits behind head on 4.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                4.x      #64      +/-   ##
============================================
+ Coverage     95.26%   95.29%   +0.02%     
- Complexity      244      248       +4     
============================================
  Files            30       30              
  Lines           782      786       +4     
============================================
+ Hits            745      749       +4     
  Misses           37       37              

☔ 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.

@roxblnfk roxblnfk merged commit c1712b6 into 4.x Jul 13, 2025
19 checks passed
@roxblnfk roxblnfk deleted the ignore-after-size-attributes branch July 13, 2025 07:22
@roxblnfk roxblnfk changed the title Ignore after size attributes Ignore after and first attributes with default values Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants