Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
Seeder is slow and inefficient because
Seeder.hasDataChanges
retrieve all data from database and compare it with the data from package.What is the new behavior?
This pull request includes significant changes to the seeder logic and database schema across multiple database systems. The most important changes include the addition of a new
SeederLogs
model, refactoring of the seeder methods to simplify the code, and the introduction of a utility function to get the installed package version.Now
hasDataChanged
is determined by the version of installedidn-area-data
package and the latest version of saved data in database (in theSeederLogs
).Database schema updates:
SeederLogs
model to the schemas for MongoDB, MySQL, PostgreSQL, and SQLite. This model includes fields forid
,dataVersion
, andcreatedAt
to track seeder execution logs. [1] [2] [3] [4]Seeder refactoring:
MongodbSeeder
class to remove redundant methods for checking data changes and deleting collections. Introduced a genericdeleteAreas
method to handle deletion for all area types.deleteAreas
andinsertAreas
methods, streamlining the deletion and insertion processes.Utility function:
getInstalledPackageVersion
to obtain the version of an installed package usingpnpm list --json
. This function is used in the seeder to compare the installed package version with the latest data version in the database.Testing:
getInstalledPackageVersion
function to verify its behavior under different scenarios, such as when the package is found, not found, or an error occurs.Other information
You need to run
db:migrate
anddb:seed
to apply this changes.