dbt's got an amazing functionality to look back at changes in your data, especially for slowly changing dimensions: Snapshots.
In snapshots, dbt will take your original table and add 3 columns, one call dbt_Updated_at to say when the last update to this row was made, dbt_VALID_FROM to say when this row in the data became valid, and dbt_VALID_TO which says when the row went through a change making it invalid.
This permits to quickly find the most recent version of a row or in another sense figure out the previous/outdated versions.
To configure a snapshot, you need to put it in a yml file, this is how to configure it:
snapshots:
name: snapshot_name
relation: ref('model_name')
config:
schema: your_schema_name
database: your_database_name
unique_key: order_id
strategy: timestamp
updated_at: date_field
Remember the indentation is very important! Once this is created, place the yml file into your snapshot folder. You can find what your snapshot folder is within your dbt_project.yml file.
The next step is just to create your snapshot, you can do this by entering into the dbt command line:
dbt snapshot
You should now be able to select from your ref function both in your database as well as within dbt using ref('snapshot_name')!
Be careful tho, these tables can get big and take up a lot of storage aka a lot of $$!