# Creating persistent models in Holistics 4.0

**URL:** <https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816>\
**Category:** Ask the Community\
**Tags:** aml\
**Created:** [March 15, 2022, 11:19am UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816 "2022-03-15T11:19:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dacou](https://community.holistics.io/user_avatar/community.holistics.io/dacou/32/467_2.png) [@dacou](https://community.holistics.io/u/dacou)\
**Post date:** [March 15, 2022, 11:19am UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816/1 "2022-03-15T11:19:50Z")

</div>

In Holistics 4.0 there is new way to create persistent models but I can’t find a way to make it work.  
I used this page for help : [Persistence Query Model | Holistics Docs](https://docs.holistics.io/docs/as-code/persistence)

I have added this block to two of my models :

```auto
  persistence: FullPersistence {
    schema: 'holistics_imports'
  }

```

and created the `schedule.aml` file next to `index.aml` :

```auto
import './matomo_final/evenements.model.aml' {evenements}
import './matomo_final/pages_vues.model.aml' {pages_vues}

const schedules = [
  Schedule {
    models: [evenements, pages_vues]
    cron: '*/15 * * * *'
  }
]

```

but nothing happens.  
Am I doing it wrong ?  
How can I debug this ? Are there logs somewhere ?

Thanks in advance for your help !  
Damien

---

<div class="post-metadata">

**Author:** ![Khai\_To](https://community.holistics.io/user_avatar/community.holistics.io/khai_to/32/128_2.png) [@Khai\_To](https://community.holistics.io/u/Khai_To)\
**Post date:** [March 15, 2022, 3:09pm UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816/2 "2022-03-15T15:09:55Z")

</div>

Hi @dacou , have you deployed to production? The persistence can only be executed in the production area.

---

<div class="post-metadata">

**Author:** ![dacou](https://community.holistics.io/user_avatar/community.holistics.io/dacou/32/467_2.png) [@dacou](https://community.holistics.io/u/dacou)\
**Post date:** [March 15, 2022, 10:40pm UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816/3 "2022-03-15T22:40:30Z")

</div>

Hi @Khai_To , Yes I did

---

<div class="post-metadata">

**Author:** ![Khai\_To](https://community.holistics.io/user_avatar/community.holistics.io/khai_to/32/128_2.png) [@Khai\_To](https://community.holistics.io/u/Khai_To)\
**Post date:** [March 16, 2022, 2:58am UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816/4 "2022-03-16T02:58:53Z")

</div>

Hi @dacou,

The filename to set schedules should be `schedules.aml` (with an `s`).  
We omitted that in our public doc, we will fix it soon.

Do let me know if you have any support.

---

<div class="post-metadata">

**Author:** ![dacou](https://community.holistics.io/user_avatar/community.holistics.io/dacou/32/467_2.png) [@dacou](https://community.holistics.io/u/dacou)\
**Post date:** [March 16, 2022, 10:43pm UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816/5 "2022-03-16T22:43:29Z")

</div>

Thanks it worked !  
But there may be an issue with the retention policy of persistent models. Apparently Holistics creates a new table everytime it refreshes a persistent model but it does not appear to delete older tables.  
Is it normal ?

---

<div class="post-metadata">

**Author:** ![Khai\_To](https://community.holistics.io/user_avatar/community.holistics.io/khai_to/32/128_2.png) [@Khai\_To](https://community.holistics.io/u/Khai_To)\
**Post date:** [March 17, 2022, 3:13am UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816/6 "2022-03-17T03:13:23Z")

</div>

Hi @dacou,

The persisted table will be invalidated in 2 cases.  
You can refer to this doc [Persistence Query Model | Holistics Docs](https://docs.holistics.io/docs/as-code/persistence#when-will-the-persisted-table-be-invalidated) for more information

 ![image](https://community.holistics.io/uploads/default/original/1X/e31ce1b1953598bb5f10864d1b7c6659ac31cfc1.png)

---

<div class="post-metadata">

**Author:** ![dacou](https://community.holistics.io/user_avatar/community.holistics.io/dacou/32/467_2.png) [@dacou](https://community.holistics.io/u/dacou)\
**Post date:** [March 17, 2022, 9:53am UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816/7 "2022-03-17T09:53:59Z")

</div>

Alright, understood. Even old versions of a persisted table are kept for 24 hours.

So we should not schedule refreshes too often otherwise the size of the database will get out of control. Do you plan to give us more control on that retention delay ?

---

<div class="post-metadata">

**Author:** ![Khai\_To](https://community.holistics.io/user_avatar/community.holistics.io/khai_to/32/128_2.png) [@Khai\_To](https://community.holistics.io/u/Khai_To)\
**Post date:** [March 17, 2022, 4:46pm UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816/8 "2022-03-17T16:46:59Z")

</div>

For now, we don’t have a plan to make the persisted\_table’s invalidation controllable @dacou.  
However, we totally understand that your schema might be messy if you’re unable to control the persistence invalidation opearation. I will note this down and improve it in the future

---

<div class="post-metadata">

**Author:** ![olammas](https://community.holistics.io/user_avatar/community.holistics.io/olammas/32/1213_2.png) [@olammas](https://community.holistics.io/u/olammas)\
**Post date:** [July 20, 2023, 6:00pm UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816/9 "2023-07-20T18:00:27Z")

</div>

I’m curious, for AML 4.0 do we expect to still have a web UI for model persistence?

---

<div class="post-metadata">

**Author:** ![Khai\_To](https://community.holistics.io/user_avatar/community.holistics.io/khai_to/32/128_2.png) [@Khai\_To](https://community.holistics.io/u/Khai_To)\
**Post date:** [July 21, 2023, 4:17am UTC](https://community.holistics.io/t/creating-persistent-models-in-holistics-4-0/816/10 "2023-07-21T04:17:14Z")

</div>

Hi @olammas,  
For now, our Persistence 4.0 is still in beta mode and doesn’t have UI option. But in the future, we definitely support UI layer for it.
