Open bbelderbos opened 2 days ago
So I followed the tutorial and I see how this migrates the tables in my data base using the Event model but it doesn't migrate the data. So I created a function to migrate the data from the sqlite db "atx_events.db" but when i checked my postgrsql database "atx-events" . One question would be do I start using my postgreSQL databse URL in the function that originally moved added my events
psql (14.13 (Homebrew))
Type "help" for help.
atx-events=# select * from event;
id | title | venue | start_datetime | category | event_link
----+-------+-------+----------------+----------+------------
(0 rows)
atx-events=#```
Yeah a migration tool like Alembic only takes care of the schema, if you want to port over any data, you'd have to write a script for that.
In this case it doesn't matter, right? Just run the scrapers again and you'll have new data.
Yes, let's use postgres from here on, you can set it in .env, something like:
DATABASE_URL=postgres://postgres:password@0.0.0.0:5432/your-db
Now when you make table changes you might have to squash your database, that is not too scalable / maintainable.
You'd typically use a db migration system, for sqlmodel/SQLAlchemy that would typically be Alembic, here is an intro video:
Database migrations matter! Get up and running with Alembic + sqlmodel https://www.youtube.com/watch?v=gekC1ESLxPs