dflourusso / expo-sqlite-orm

Expo SQLite ORM
141 stars 34 forks source link

Question: Do migrations run again if in db? #73

Closed Zer0-213 closed 2 months ago

Zer0-213 commented 2 months ago

Hi I am writing up migrations for my project with this library. I wanted to ask if migrations that are stored in the db run or are they checked by the library?

FelipeBohnertPaetzold commented 2 months ago

Hello, you need to run the migrations using the library, as shown in the README example.

import { Migrations } from 'expo-sqlite-orm'

const migrations = useMemo(() => new Migrations(databaseName, statements), [])

const onPressRunMigrations = async () => {
  await migrations.migrate()
}

const onPressReset = async () => {
  await migrations.reset()
}

You need to manually create your migrations with an ascending key and execute the necessary SQL in the migration. The library will manage which migrations have already been executed. See more at the link.

https://github.com/dflourusso/expo-sqlite-orm?tab=readme-ov-file#migrations

Zer0-213 commented 2 months ago

Perfect thank you. Closing the issue