openclimatefix / pv-site-datamodel

Datamodel for PV sites
MIT License
2 stars 9 forks source link

Site history table #165

Open peterdudfield opened 1 month ago

peterdudfield commented 1 month ago

Detailed Description

It would be good to store the history of site changes.

Context

Possible Implementation

mduffin95 commented 1 month ago

I can take a look at this

mduffin95 commented 1 month ago

How will the history table be used?

I ask because an alternative approach would be to use triggers to store the old record in a JSONB column in a history table every time the sites table is updated. This has the advantage of being easier to migrate over time as it doesn't use such a rigid schema. However that schema might be required if we want to query the data.

Do you think this approach would be sufficient?

peterdudfield commented 1 month ago

Hey,

Yea idea with the json column. Thats definitely something we could do.

We will likely not query it that much, apart from looking at the history of one site. And see the 5 to 10 updates its had. I dont think it'll be thousands. I like the idea, means if the site table schema changes, then we would not have to worry about destroying the history table.

So perhaps the columns would be

mduffin95 commented 1 week ago

@peterdudfield added an initial preparatory PR.