hhtokpinar / sqfEntity

SqfEntity ORM for Flutter/Dart lets you build and execute SQL commands on SQLite database easily and quickly with the help of fluent methods similar to .Net Entity Framework. SqfEntity also generates add/edit forms with validations and special controls (DropDown List, DateTime pickers, Checkboxes.. etc) for your table.
379 stars 101 forks source link

Multiple requests of creating/updading database/table #292

Open priyankmodi3 opened 1 year ago

priyankmodi3 commented 1 year ago

Error Stack: Restarted application in 2,414ms. I/flutter (10267): init() -> tableName:category I/flutter (10267): init() -> tableName:profile I/flutter (10267): Inside init state I/flutter (10267): SQFENTITIY: Table named [category] was initialized successfully (No added new columns) I/flutter (10267): SQFENTITIY: Table named [category] was initialized successfully (No added new columns) I/flutter (10267): SQFENTITIY: Table named [profile] was initialized successfully (No added new columns) I/flutter (10267): SQFENTITIY: The database is ready for use I/flutter (10267): SQFENTITIY: Table named [profile] was initialized successfully (No added new columns) I/flutter (10267): SQFENTITIY: The database is ready for use

On hard loading the application or running first time, it tries to create database/table multiple times. Below is my modal.dart file code


import 'package:sqfentity_gen/sqfentity_gen.dart';

part 'database_modal.g.dart';

const SqfEntityTable tableCategory = SqfEntityTable(
    tableName: 'category',
    primaryKeyName: 'id',
    primaryKeyType: PrimaryKeyType.integer_auto_incremental,
    useSoftDeleting: true,
    modelName: null,
    fields: [
      SqfEntityField('name', DbType.text),
    ]);

const SqfEntityTable tableProfile = SqfEntityTable(
    tableName: 'profile',
    primaryKeyName: 'id',
    primaryKeyType: PrimaryKeyType.integer_auto_incremental,
    useSoftDeleting: true,
    modelName: null,
    fields: [
      SqfEntityField('name', DbType.text)
    ]);

const SqfEntitySequence seqIdentity = SqfEntitySequence(
  sequenceName: 'identity',
  // maxValue: 10000, /* optional. default is max int (9.223.372.036.854.775.807) */
  //modelName: 'SQEidentity',
  /* optional. SqfEntity will set it to sequenceName automatically when the modelName is null*/
  //cycle : false,    /* optional. default is false; */
  //minValue = 0;     /* optional. default is 0 */
  //incrementBy = 1;  /* optional. default is 1 */
  // startWith = 0;   /* optional. default is 0 */
);

@SqfEntityBuilder(myDbModel)
const SqfEntityModel myDbModel = SqfEntityModel(
    modelName: 'MyAppDatabaseModel',
    databaseName: 'doc_vault_with_orm2.db',
    sequences: [seqIdentity],
    databaseTables: [tableCategory, tableProfile],
    // formTables: [tableCategory],
    // put defined sequences into the sequences list.
    // bundledDatabasePath: null // 'assets/sample.db' // This value is optional. When bundledDatabasePath is empty then EntityBase creats a new database when initializing the database
    );