NAL-i5K / tripal_chado_datasets

Provides an admin layer and forms for users to submit organisms and analysis into Chado
0 stars 0 forks source link

SEQUENCE causing issues in install/disable #24

Closed bradfordcondon closed 5 years ago

bradfordcondon commented 5 years ago

In the install hook, we set up the tables that arent defined in schema: the "SEQUENCE" tables.

 $sql = 'CREATE SEQUENCE gene_prediction_pid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1';

    db_query($sql);

 $sql = 'CREATE SEQUENCE mapped_dataset_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1';

    db_query($sql);

   $t = get_t();
   drupal_set_message($t('datasets module was installed.'), 'status');

//in uninstall...
 $sql = "DROP SEQUENCE gene_prediction_pid_seq";

  db_query($sql);

  $sql = "DROP SEQUENCE mapped_dataset_id_seq";
  db_query($sql);
bradfordcondon commented 5 years ago

uninstall fails like so:

Wrong object type: 7 ERROR:  "gene_prediction_pid_seq" is not a sequence                         [error]
HINT:  Use DROP TABLE to remove a table. in /Users/chet/UTK/tripal/includes/database/database.inc:2227
Stack trace:
bradfordcondon commented 5 years ago

edit: dropping table fails because:

 Wrong object type: 7 ERROR:  "gene_prediction_pid_seq" is not a table                            [error]
HINT:  Use DROP SEQUENCE to remove a sequence. in /Users/chet/UTK/tripal/includes/database/database.inc:2227
Stack trace:
bradfordcondon commented 5 years ago

gene_prediction_pid_seq is not used elsewhere in the code. I think we can safely cut it. It was used to define the PKEY of ds_gene_prediction.

 'fields' => [
      'pid' => [
        'description' => 'Primary Key: Unique ID.',
        'type' => 'serial',
        'not null' => TRUE,
      ],

Serial is indeed the autoincrement type so we just dont need the SEQUENCE. Same is true for mapped_dataset_id_seq.

So in both cases we can safely delete the tables.