I am making a simple note app, and I want to create a table to track a note's edit history and save them with an incrementing version as a composite key with the note's id. So for example:
note_id | version | content
----------------------------
1 | 1 | some_text
1 | 2 | some_text
2 | 1 | some_text
2 | 2 | some_text
1 | 3 | some_text
3 | 1 | some_text
1 | 4 | some_text
The composite key is made up of note_id and version I want to increment version for each note_id Is there a way to automate this? I have seen some other posts, and experimented with triggers and functions, but I have not yet been able to get anything to work. Any advice is greatly appreciated!