Skip to content

Conversation

@zimt28
Copy link
Contributor

@zimt28 zimt28 commented Apr 28, 2021

A new PR as I messed up the Git history on the old one. I've deleted the priv/ folder and run the migrations, but I'm still getting this:

def up do
  create table(:posts, primary_key: false) do
    add :id, :uuid, null: false, default: fragment("uuid_generate_v4()"), primary_key: true
    add :title, :text
    add :score, :bigint
    add :public, :boolean
    add :category, :citext
    add :type, :text, default: "sponsored"
    add :price, :bigint
  end

  create constraint(:posts, :price_must_be_positive, check: "type = 'sponsored' AND price > 0")

  alter table(:posts) do
    add :decimal, :decimal, default: 0
    add :status, :status
  end

@zachdaniel
Copy link
Contributor

Ah, I think we need to add logic to push constraints to the bottom as well.

@zachdaniel
Copy link
Contributor

but it looks like your PR is working as intended. Probably will have unexpected ordering when multiple resources uses the same table, but that doesn't really matter.

@zimt28 zimt28 marked this pull request as ready for review April 28, 2021 21:15
@zachdaniel zachdaniel changed the title Preserve attribute order improvement: Preserve attribute order Apr 28, 2021
@zachdaniel zachdaniel merged commit fe7d188 into ash-project:master Apr 28, 2021
@zachdaniel
Copy link
Contributor

Great work!

🚀 Thank you for your contribution! 🚀

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.

2 participants