How do I apply git commits to the app

Hi, I did some changes to the yaml file

git add anvil.yaml
git commit -m 'Update db'
git push origin master

I see the commit in Version History and the last commit is selected “Master → Published” but I don’t see any changes on the web page or if I clone the repo again.

I’m assuming from your commit message, that you’re expecting to see that the db has changed somehow…

In which case, have you opened the db designer in the IDE and applied any migrations from there?

How do I do that? I see the changes in App Schema but not on database page,

You’d normally see a warning that the db doesn’t match the schema. If you then follow the link in that warning, you get to decide how to handle that mismatch.

I don’t see any warning.
I assume some options in yaml are ignored by IDE and tables API.

At this point, I think you need to share some code and show us exactly what’s not behaving as you expect.

I can’t do much more by guesswork.

Db columns in yaml:

    - admin_ui: {order: 0, width: 200}
      name: Food
      type: string
    - admin_ui: {order: 1, width: 200}
      name: Water [G]
      type: string
    - admin_ui: {order: 2, width: 200}
      name: Energy [KCAL]
      type: string
    - admin_ui: {order: 3, width: 200}
      name: Protein [G]
      type: string`

Db columns display on IDE data page:

Table API response:

[{"Vitamin A, RAE [UG]":"0","Fiber, total dietary [G]":"0.0","Iodine, I [UG]":"0","Energy [KCAL]":"141.0","Protein [G]":"21.57"...

From my other/similar post, I understand that IDE uses yaml file for displaying columns:

Evidently, this affects only the order in which the IDE displays the columns. The order in which search() returns them, within a row, cannot be relied on.

I have seen Anvil reorder dictionaries when passed via an anvil.server.call, which is consistent with Python’s own [lack of] ordering guarantees for Python 3.6 and earlier: order is not guaranteed. I expect the same reordering can take place for any table row.

If you want to process things in a consistent order, start with an order-preserving object: a list, e.g., a list of column names. That ordering will remain consistent for the lifetime of the list.

Rather than me or anyone else having to spend time attempting to work out what the problem is, could you please spell out what exactly is not as you expect.

1 Like

I understand that search() ignores the yaml file but why does IDE? You can see in the image above the columns in IDE are not in the same order as in the yaml file.

  1. Try an IDE-side Commit, and then a git pull on your PC, to see what the App’s current anvil.yaml file looks like. Do they still disagree?

  2. If you merely want to rearrange the columns in the IDE, you can just drag their headers left and right.

1 Like

It seems the order from yaml is ignored also the “order: integer” is also ignored.
The only way to change it is with mouse drag which will add “integer: -integer/float” which I don’t understand:

- admin_ui: {order: -1, width: 402}
- admin_ui: {order: -0.5, width: 200}
- admin_ui: {order: -0.25, width: 200}

Is there a way to (re)create with code only the columns?

If you sort by this value, I would expect you to get the columns in the IDE’s order.

This is a long-standing Feature Request. You can tell an App to add missing columns, when referenced; but then any typos or bugs in your code could end up adding unwanted columns, so most of us leave that feature turned off. Otherwise, Application code cannot manage table structure, only its content.

1 Like

Just to confirm some things

When we load the database in the IDE we consider what is stored in the database as the source of truth.

When there is a mismatch between your yaml column definitions and the Database column definitions we show you a schema mismatch link.
However, for convenience, we don’t consider the order of columns as a schema mismatch.

So the only way to re-order columns, is to do it via the UI i’m afraid.

3 Likes