Problem during Forest Admin Backend initial loading (model creation error)

Hello,

When I try to run the Forest Admin in development mode, I have the following messages:

ubuntu@ubuntu:~/Documents/vi-utilities-webadmin-test/vi-utilities-webadmin-dashboard$ npm start

> vi-utilities-webadmin-dashboard@0.0.1 start /home/ubuntu/Documents/vi-utilities-webadmin-test/vi-utilities-webadmin-dashboard
> node ./server.js

Model creation error: Error: A column called 'id' was added to the attributes of 'auth_group_permissions' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'auth_group' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'auth_permission' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'auth_user_groups' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'auth_user_user_permissions' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'auth_user' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'django_admin_log' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'django_content_type' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'django_migrations' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'hr_scanner_kioskentry' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'production_enduser_users' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'production_enduser' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'production_historicalkiosk' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'production_kiosk' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'production_kioskcommand' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'production_kioskdiagnostics' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'production_scan' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'production_smrelease' but not marked with 'primaryKey: true'
Model creation error: Error: A column called 'id' was added to the attributes of 'production_vssrelease' but not marked with 'primaryKey: true'
(node:16552) [SEQUELIZE0004] DeprecationWarning: A boolean value was passed to options.operatorsAliases. This is a no-op with v5 and should be removed.
(Use `node --trace-deprecation ...` to show where the warning was created)
Your application is listening on port 3310.
Your admin panel is available here: https://app.forestadmin.com/projects

When accessing the project on the ForestAdmin website, I have this behavior:

The database is Postgresql.

Looking at the database, the ‘id’ field is the primary key. Here is a screen from pgadmin.

Can you give me some advice in how to address this issue?

Best regards,

Flavio

Hello @Flavio_Alves

Thank you for sharing this.

Would you mind sharing the definition for this model? Both SQL create statement and the generated JS file if you can.
This will help me reproduce and investigate the issue.

Can you also tell me which version for forest-express-sequelize and which version of postgreSQL you are using?

I also see that some of the model listed are Django internal tables. If you have no use for them within your Forest admin panel, you can exclude them (instead of simply hiding them). Please have a look at the documentation if you feel it could help.

Thank you

Hello @anon79585656 ,

Thank you for your fast response.

To solve this issue, I entered on the model js file in model/ directory and added the field ‘primaryKey: true’ for the id configuration.

The error disappears, but the data is not loaded correctly anyway.

Best regards.

Flavio

@Flavio_Alves,

Thank you for the update.

When you say the data is not loading correctly, is it not loading at all? Or are you missing part of it?
Let me know if I can help more.

You can start the Forest agent with DEBUG=sequelize* npm start or DEBUG=* npm start to get more info on what is happening and see what queries are run.

Best regards.

Hello @anon79585656 ,

Launching the agent with debug activated, I have these messages:

ubuntu@ubuntu:~/Documents/vi-utilities-webadmin$ DEBUG=sequelize* npm start

> vi-utilities-webadmin@0.0.1 start /home/ubuntu/Documents/vi-utilities-webadmin
> node ./server.js

  sequelize:pool pool created with max/min: 5/0, no replication +0ms
Your application is listening on port 3310.
Your admin panel is available here: https://app.forestadmin.com/projects
POST /forest/authentication 200 1040 - 2022.465 ms
OPTIONS /forest/authentication/callback?code=5uoGDqNuiSbEl2Udo_J_MJrpD-kx2n4Quu_yigAKmVXTym7yKD3THlFdIeslZiLs&state=%7B%22renderingId%22%3A97988%7D 204 0 - 0.905 ms
GET /forest/authentication/callback?code=5uoGDqNuiSbEl2Udo_J_MJrpD-kx2n4Quu_yigAKmVXTym7yKD3THlFdIeslZiLs&state=%7B%22renderingId%22%3A97988%7D 200 484 - 2610.562 ms
  sequelize:connection:pg connection acquired +0ms
  sequelize:connection:pg connection acquired +1s
  sequelize:connection:pg connection acquired +2ms
  sequelize:pool connection acquired +40s
  sequelize:pool connection acquired +1ms
  sequelize:sql:pg Executing (default): SELECT count(*) AS "count" FROM "public"."django_session" AS "djangoSession"; +0ms
Executing (default): SELECT count(*) AS "count" FROM "public"."django_session" AS "djangoSession";
  sequelize:sql:pg Executing (default): SELECT "session_key" AS "sessionKey", "session_data" AS "sessionData", "expire_date" AS "expireDate" FROM "public"."django_session" AS "djangoSession" LIMIT 15 OFFSET 0; +1ms
Executing (default): SELECT "session_key" AS "sessionKey", "session_data" AS "sessionData", "expire_date" AS "expireDate" FROM "public"."django_session" AS "djangoSession" LIMIT 15 OFFSET 0;
  sequelize:sql:pg Executed (default): SELECT count(*) AS "count" FROM "public"."django_session" AS "djangoSession"; +152ms
  sequelize:pool connection released +174ms
  sequelize:sql:pg Executed (default): SELECT "session_key" AS "sessionKey", "session_data" AS "sessionData", "expire_date" AS "expireDate" FROM "public"."django_session" AS "djangoSession" LIMIT 15 OFFSET 0; +4ms
  sequelize:pool connection released +24ms
GET /forest/djangoSession/count?fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey&searchExtended=0&timezone=America%2FSao_Paulo 200 12 - 3798.512 ms
GET /forest/djangoSession?timezone=America%2FSao_Paulo&fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0 200 5592 - 4003.288 ms
  sequelize:pool connection destroy +10s
  sequelize:pool connection destroy +1s

Here is the picture of the web:

And after a few seconds:

Here is the table SQL structure that I intend to work on:

vi-test=> \d production_kioskdiagnostics
                                           Table "public.production_kioskdiagnostics"
        Column         |          Type          | Collation | Nullable |                         Default                         
-----------------------+------------------------+-----------+----------+---------------------------------------------------------
 id                    | integer                |           | not null | nextval('production_kioskdiagnostics_id_seq'::regclass)
 timestamp             | double precision       |           | not null | 
 pc_temp               | double precision       |           | not null | 
 vss_framerate         | double precision       |           | not null | 
 vss_overload_rate     | double precision       |           | not null | 
 pc_uptime             | integer                |           | not null | 
 kiosk_id              | integer                |           | not null | 
 vss_running           | boolean                |           | not null | 
 camera_settings       | text                   |           | not null | 
 hdd_available         | integer                |           | not null | 
 hdd_total             | integer                |           | not null | 
 mem_available         | integer                |           | not null | 
 mem_total             | integer                |           | not null | 
 sm_backup_mode        | boolean                |           | not null | 
 sm_settings           | text                   |           | not null | 
 sm_version            | character varying(32)  |           | not null | 
 vss_diagnostic_counts | integer                |           | not null | 
 vss_scans_per_hour    | double precision       |           | not null | 
 vss_total_scans       | integer                |           | not null | 
 vss_uptime            | integer                |           | not null | 
 vss_version           | character varying(32)  |           | not null | 
 vss_args              | character varying(128) |           | not null | 
Indexes:
    "production_kioskdiagnostics_pkey" PRIMARY KEY, btree (id)
    "production_kioskdiagnostics_kiosk_id_1e70c145" btree (kiosk_id)
    "production_kioskdiagnostics_timestamp_57290b33" btree ("timestamp")
Foreign-key constraints:
    "production_kioskdiag_kiosk_id_1e70c145_fk_productio" FOREIGN KEY (kiosk_id) REFERENCES production_kiosk(id) DEFERRABLE INITIALLY DEFERRED

And here there is the content of the models/js file related to this table:

// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
  const { Sequelize } = sequelize;
  // This section contains the fields of your model, mapped to your table's columns.
  // Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
  const ProductionKioskdiagnostics = sequelize.define('productionKioskdiagnostics', {
    id: {
      type: DataTypes.INTEGER,
      defaultValue: Sequelize.literal('nextval(\'production_kioskdiagnostics_id_seq\'::regclass)'),
      allowNull: false,
      primaryKey: true,
    },
    timestamp: {
      type: DataTypes.DOUBLE,
      allowNull: false,
    },
    pcTemp: {
      type: DataTypes.DOUBLE,
      allowNull: false,
    },
    vssFramerate: {
      type: DataTypes.DOUBLE,
      allowNull: false,
    },
    vssOverloadRate: {
      type: DataTypes.DOUBLE,
      allowNull: false,
    },
    pcUptime: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    kioskId: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    vssRunning: {
      type: DataTypes.BOOLEAN,
      allowNull: false,
    },
    cameraSettings: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    hddAvailable: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    hddTotal: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    memAvailable: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    memTotal: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    smBackupMode: {
      type: DataTypes.BOOLEAN,
      allowNull: false,
    },
    smSettings: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    smVersion: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    vssDiagnosticCounts: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    vssScansPerHour: {
      type: DataTypes.DOUBLE,
      allowNull: false,
    },
    vssTotalScans: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    vssUptime: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    vssVersion: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    vssArgs: {
      type: DataTypes.STRING,
      allowNull: false,
    },
  }, {
    tableName: 'production_kioskdiagnostics',
    underscored: true,
    timestamps: false,
    schema: process.env.DATABASE_SCHEMA,
  });

  // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
  ProductionKioskdiagnostics.associate = (models) => {
  };

  return ProductionKioskdiagnostics;
};

Looking forward to your remarks.

Best regards,

Flavio

Hello @Flavio_Alves,

Thank you for the details.

I find it strange that there is no error in the Forest agent log given the message in the web admin.
Could you check the network tab and the console of you browser developper tools?
Please check if the call to GET /forest/djangoSession returns some data from your agent.

Hello @anon79585656 ,

Here is the console tab:

Here is the network tab:

I reloaded the page and could see more messages. I found the djangoSession that you requested. Here it is:

And finally what happened on the ForestAdmin agent:

I still have no idea about what is causing this behavior.

Looking forward to your comments.

Best regards,

Flavio

Hi @Flavio_Alves :wave:

I guess @anon79585656 was asking for the response of the GET request on /forest/djangoSession call, not the /forest/djangoSession/count one.

The issue looks pretty similar to this thread, and we just need to make sure that the GET /forest/djangoSession actually return data or if the issue is located elsewhere (It looks like it does though, since I can see a 304 for this call on your last screenshot - But seeing the actual content of the request might help to investigate what is happing here)

Thanks in advance :pray:

Hello @jeffladiray and @anon79585656 ,

Indeed … sorry for the confusion.

Here is the content of the response for djangoSession:

{"data":[{"type":"djangoSession","attributes":{"sessionKey":"3c48y48j3pztnlpfvl78zr1x40w87wq1","sessionData":".eJxVjDsOwjAQBe_iGlnxbxNT0nOGaL27xgHkSHFSIe4OkVJA-2bmvdSI21rGrckyTqzOyqrT75aQHlJ3wHest1nTXNdlSnpX9EGbvs4sz8vh_h0UbOVbZyYPbGEIZL1ECZ2DPkfXRdP3TjoS46MDm6MAmJAcZgwDDDlDQiZS7w_TCzfv:1lEnFY:VUTsgWx5SCzOfl2JP_pNZYypx-0NxCKN-_AkpfSG8Mo","expireDate":"2021-03-10T06:02:16.537Z"}},{"type":"djangoSession","attributes":{"sessionKey":"kosxvheq68mtqb7e1qqrcn769749hove","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lEnM1:Fi2Scn7XzzaoI7Y9Hjxov-3OJb3FXlmdtFoV8eYR2E8","expireDate":"2021-03-10T06:08:57.693Z"}},{"type":"djangoSession","attributes":{"sessionKey":"l4ig8gyhhqc0bhgzadieimaue6ir7qg2","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lUiy2:GVE_dXkaGwzDo51--szVHPWVAPTxzv0rj4I1slj5xcQ","expireDate":"2021-04-23T04:42:02.210Z"}},{"type":"djangoSession","attributes":{"sessionKey":"qbjgh8swgtgo2e44paps4tx0g1bgnube","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lUiyP:gAzeVNENJX7DW1MXGRzzlSnK5oGf8qACPXWnSHgM7Q8","expireDate":"2021-04-23T04:42:25.437Z"}},{"type":"djangoSession","attributes":{"sessionKey":"oz79svfq50cn0d1ot6em8qzktadh321s","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lUiyP:gAzeVNENJX7DW1MXGRzzlSnK5oGf8qACPXWnSHgM7Q8","expireDate":"2021-04-23T04:42:25.887Z"}},{"type":"djangoSession","attributes":{"sessionKey":"i2jro9xd12ubqphlet56bwt87o3ed12m","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lUjLu:yqianN2JGRY5n4uTsNENxyPBwgey7SmxDBuN-20wu00","expireDate":"2021-04-23T05:06:42.287Z"}},{"type":"djangoSession","attributes":{"sessionKey":"wmasa1vura8cw97pgbk47u2pn9j0usyt","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lV0Rp:hZ7nT_vDebGWZzRHC1UyQ9RXr9fdDI_DFvTRFYIxD6g","expireDate":"2021-04-23T23:21:57.702Z"}},{"type":"djangoSession","attributes":{"sessionKey":"bc7z5gmrx7gnbh3bbsan2rxyipjnpjvv","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lW5pf:7q8odNV2wm4KgULM2fpZVop6UdJbZmbY7_ngftkqnr0","expireDate":"2021-04-26T23:19:03.928Z"}},{"type":"djangoSession","attributes":{"sessionKey":"k2l16dqn8ht2a1ig89z2gttltoduun0w","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lW5q4:9QBiYNEJUEmkGHYjhVx0I0CQbgQS8Rhg1cni1UTQr8o","expireDate":"2021-04-26T23:19:28.536Z"}},{"type":"djangoSession","attributes":{"sessionKey":"lc1rtuoihem74vdd9bkskpo2z8k36yvn","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lcKKQ:Lj7P3IY0hoNk5L5ZbyNuEqLFjxt0CHTGPUc3At3ejM4","expireDate":"2021-05-14T04:00:34.978Z"}},{"type":"djangoSession","attributes":{"sessionKey":"9e5o6denr5n1d1aeryrkyifiaesuizep","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lcKUv:MYYY8mHxFasa_zfIFwmIISn8IRgc8fWaQk_RdZttJCk","expireDate":"2021-05-14T04:11:25.583Z"}},{"type":"djangoSession","attributes":{"sessionKey":"xiqwt0x9lm33872yihhjf8zx0lc3s49a","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lcKvE:RkfBT555LQ-hHqM5DyeHtoFKI-W1_GYlpkLg7HpAcJw","expireDate":"2021-05-14T04:38:36.227Z"}},{"type":"djangoSession","attributes":{"sessionKey":"z8iwral40nvyxksdndhz0x5a1p53gwq7","sessionData":".eJxVjDsOwjAQBe_iGlnxbxNT0nOGaL27xgHkSHFSIe4OkVJA-2bmvdSI21rGrckyTqzOyqrT75aQHlJ3wHest1nTXNdlSnpX9EGbvs4sz8vh_h0UbOVbZyYPbGEIZL1ECZ2DPkfXRdP3TjoS46MDm6MAmJAcZgwDDDlDQiZS7w_TCzfv:1lcL7X:n96y7DxRt63KOveq5dqcRcsH1M4kzqtwuZNoaLsfw00","expireDate":"2021-05-14T04:51:19.509Z"}},{"type":"djangoSession","attributes":{"sessionKey":"u9v0pqck11piaa3wbpi6whyacmz1wyez","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lcN8i:HGIC0YglTpNmk4a-nSxI9_nsH4R4vJ2NFBNlhNRmUFs","expireDate":"2021-05-14T07:00:40.858Z"}},{"type":"djangoSession","attributes":{"sessionKey":"yld6jxbyu2d7rp7pl0rb8qzhz5uspjtu","sessionData":".eJxVjEEOwiAQRe_C2hA7FASX7nsGMsMMUjU0Ke3KeHfbpAvd_vfef6uI61Li2mSOI6urAnX63QjTU-oO-IH1Puk01WUeSe-KPmjTw8Tyuh3u30HBVrbaBgDvHVoLOeeLgHTBmp48c8rkrQQTjCdHvYEuZRBKm8R0BnEUHKrPF-C0OEk:1lcNAE:34D5H9VOUMBuZltpkKigQvdZByZ4LV7ljCBj7e86jRM","expireDate":"2021-05-14T07:02:14.107Z"}}]}

Below the correct print:

According to the print, it seems that this response is cached. Is it good?

Below the activity in the agent:

Your application is listening on port 3310.
Your admin panel is available here: https://app.forestadmin.com/projects
OPTIONS /forest/authentication 204 0 - 2.945 ms
POST /forest/authentication 200 1040 - 1960.879 ms
OPTIONS /forest/authentication/callback?code=3oH1a2po-uml7XfBbYDUHegtOlqyyBfC-RfmI3jfQENujkx-bZLIZuVpV7RwEg6Z&state=%7B%22renderingId%22%3A97988%7D 204 0 - 2.161 ms
GET /forest/authentication/callback?code=3oH1a2po-uml7XfBbYDUHegtOlqyyBfC-RfmI3jfQENujkx-bZLIZuVpV7RwEg6Z&state=%7B%22renderingId%22%3A97988%7D 200 484 - 2649.789 ms
OPTIONS /forest/djangoSession?timezone=America%2FSao_Paulo&fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0 204 0 - 0.164 ms
OPTIONS /forest/djangoSession/count?fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey&searchExtended=0&timezone=America%2FSao_Paulo 204 0 - 0.568 ms
Executing (default): SELECT "session_key" AS "sessionKey", "session_data" AS "sessionData", "expire_date" AS "expireDate" FROM "public"."django_session" AS "djangoSession" LIMIT 15 OFFSET 0;
Executing (default): SELECT count(*) AS "count" FROM "public"."django_session" AS "djangoSession";
GET /forest/djangoSession/count?fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey&searchExtended=0&timezone=America%2FSao_Paulo 200 12 - 3592.216 ms
GET /forest/djangoSession?timezone=America%2FSao_Paulo&fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0 304 - - 3849.987 ms
POST /forest/authentication 200 1040 - 15.971 ms
OPTIONS /forest/authentication/callback?code=ZACf0S-SGVfvSCjoTOWdEa_5AgkheiMNL3GV9gIS0SdmVJ84h0-Nwx6kXRrOLc47&state=%7B%22renderingId%22%3A97988%7D 204 0 - 0.288 ms
GET /forest/authentication/callback?code=ZACf0S-SGVfvSCjoTOWdEa_5AgkheiMNL3GV9gIS0SdmVJ84h0-Nwx6kXRrOLc47&state=%7B%22renderingId%22%3A97988%7D 200 484 - 1709.249 ms
Executing (default): SELECT "session_key" AS "sessionKey", "session_data" AS "sessionData", "expire_date" AS "expireDate" FROM "public"."django_session" AS "djangoSession" LIMIT 15 OFFSET 0;
Executing (default): SELECT count(*) AS "count" FROM "public"."django_session" AS "djangoSession";
GET /forest/djangoSession?timezone=America%2FSao_Paulo&fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0 304 - - 784.953 ms
GET /forest/djangoSession/count?fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey&searchExtended=0&timezone=America%2FSao_Paulo 304 - - 768.787 ms
POST /forest/authentication 200 1040 - 1.706 ms
OPTIONS /forest/authentication/callback?code=_8HiPnkFnTCAdIWajj5BCKG8l6r5mh4mv7aPvgPPVsiYY5YU4lUTyNsCxoN8f-Oi&state=%7B%22renderingId%22%3A97988%7D 204 0 - 0.145 ms
GET /forest/authentication/callback?code=_8HiPnkFnTCAdIWajj5BCKG8l6r5mh4mv7aPvgPPVsiYY5YU4lUTyNsCxoN8f-Oi&state=%7B%22renderingId%22%3A97988%7D 200 484 - 2435.247 ms
Executing (default): SELECT "session_key" AS "sessionKey", "session_data" AS "sessionData", "expire_date" AS "expireDate" FROM "public"."django_session" AS "djangoSession" LIMIT 15 OFFSET 0;
Executing (default): SELECT count(*) AS "count" FROM "public"."django_session" AS "djangoSession";
GET /forest/djangoSession?timezone=America%2FSao_Paulo&fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0 304 - - 778.417 ms
GET /forest/djangoSession/count?fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey&searchExtended=0&timezone=America%2FSao_Paulo 304 - - 632.775 ms

I hope now I could provide better information.

Best regards,

Flavio

1 Like

Hey @Flavio_Alves,

That’s exactly what I needed.

It appear that the response for /djangoSession does not have an id field in the response, similar to the thread I shared you previously (And I opened a issue on our end to have a clear log in the browser when this happen).

The cached response behavior you’re having is normal.

Normally, forest-express-sequelize should be able to locate your primary key.
Could you share the generated model definition for djangoSession ?

Thanks in advance

Hello @jeffladiray ,

Sure. Here it is:

// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
  const { Sequelize } = sequelize;
  // This section contains the fields of your model, mapped to your table's columns.
  // Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
  const DjangoSession = sequelize.define('djangoSession', {
    sessionKey: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    sessionData: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    expireDate: {
      type: DataTypes.DATE,
      allowNull: false,
    },
  }, {
    tableName: 'django_session',
    underscored: true,
    timestamps: false,
    schema: process.env.DATABASE_SCHEMA,
  });
  DjangoSession.removeAttribute('id');
  // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
  DjangoSession.associate = (models) => {
  };

  return DjangoSession;
};

There is a removeAttribute configuration for the id field here :expressionless:

Best regards,

Flavio

Ok, that explains why you don’t have access to this collection. Could you try to comment out this line & restart your server just to check if this djangoSession collection is working?

If not, please re-share the content of the response once that’s done, but this is most likely your issue here.

I commented this line and restarted. O got an error on the agent:

Your application is listening on port 3310.
Your admin panel is available here: https://app.forestadmin.com/projects
POST /forest/authentication 200 1040 - 1730.173 ms
OPTIONS /forest/authentication/callback?code=ISuS9pQux_e_sH2RboHWnA1prc8Vt2vW7T1LsEwUg6qoJP6EerxXdn36nfE08tgt&state=%7B%22renderingId%22%3A97988%7D 204 0 - 1.209 ms
GET /forest/authentication/callback?code=ISuS9pQux_e_sH2RboHWnA1prc8Vt2vW7T1LsEwUg6qoJP6EerxXdn36nfE08tgt&state=%7B%22renderingId%22%3A97988%7D 200 484 - 2441.734 ms
GET /forest/hrScannerProcessedvideo/count?fields%5BhrScannerProcessedvideo%5D=br%2Cbucket%2Chr%2Ckey%2Csp&searchExtended=0&timezone=America%2FSao_Paulo - - - - ms
GET /forest/hrScannerProcessedvideo?timezone=America%2FSao_Paulo&fields%5BhrScannerProcessedvideo%5D=br%2Cbucket%2Chr%2Ckey%2Csp&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0 - - - - ms
OPTIONS /forest/djangoSession?timezone=America%2FSao_Paulo&fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey%2Cid&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0 204 0 - 0.287 ms
OPTIONS /forest/djangoSession/count?fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey%2Cid&searchExtended=0&timezone=America%2FSao_Paulo 204 0 - 0.146 ms
Executing (default): SELECT "bucket", "key", "hr", "br", "sp" FROM "public"."hr_scanner_processedvideo" AS "hrScannerProcessedvideo" LIMIT 15 OFFSET 0;
Executing (default): SELECT count(*) AS "count" FROM "public"."hr_scanner_processedvideo" AS "hrScannerProcessedvideo";
Executing (default): SELECT "id", "session_key" AS "sessionKey", "session_data" AS "sessionData", "expire_date" AS "expireDate" FROM "public"."django_session" AS "djangoSession" LIMIT 15 OFFSET 0;
Executing (default): SELECT count(*) AS "count" FROM "public"."django_session" AS "djangoSession";
[forest] 🌳🌳🌳  Unexpected error: column "id" does not exist
{
  "name": "SequelizeDatabaseError",
  "parent": {
    "length": 101,
    "name": "error",
    "severity": "ERROR",
    "code": "42703",
    "position": "8",
    "file": "parse_relation.c",
    "line": "3359",
    "routine": "errorMissingColumn",
    "sql": "SELECT \"id\", \"session_key\" AS \"sessionKey\", \"session_data\" AS \"sessionData\", \"expire_date\" AS \"expireDate\" FROM \"public\".\"django_session\" AS \"djangoSession\" LIMIT 15 OFFSET 0;"
  },
  "original": {
    "length": 101,
    "name": "error",
    "severity": "ERROR",
    "code": "42703",
    "position": "8",
    "file": "parse_relation.c",
    "line": "3359",
    "routine": "errorMissingColumn",
    "sql": "SELECT \"id\", \"session_key\" AS \"sessionKey\", \"session_data\" AS \"sessionData\", \"expire_date\" AS \"expireDate\" FROM \"public\".\"django_session\" AS \"djangoSession\" LIMIT 15 OFFSET 0;"
  },
  "sql": "SELECT \"id\", \"session_key\" AS \"sessionKey\", \"session_data\" AS \"sessionData\", \"expire_date\" AS \"expireDate\" FROM \"public\".\"django_session\" AS \"djangoSession\" LIMIT 15 OFFSET 0;",
  "stack": "SequelizeDatabaseError: column \"id\" does not exist\n    at Query.formatError (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/lib/dialects/postgres/query.js:354:16)\n    at /home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/lib/dialects/postgres/query.js:71:18\n    at tryCatcher (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)\n    at Promise._settlePromise (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)\n    at Promise._settlePromise0 (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)\n    at Promise._settlePromises (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:725:18)\n    at _drainQueueStep (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)\n    at _drainQueue (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)\n    at Async._drainQueues (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)\n    at Immediate.Async.drainQueues [as _onImmediate] (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)\n    at processImmediate (internal/timers.js:464:21)"
}
GET /forest/djangoSession?timezone=America%2FSao_Paulo&fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey%2Cid&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0 500 99 - 1539.689 ms
GET /forest/djangoSession/count?fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey%2Cid&searchExtended=0&timezone=America%2FSao_Paulo 200 12 - 1408.555 ms
POST /forest/authentication 200 1040 - 2.346 ms
OPTIONS /forest/authentication/callback?code=j4WLQoFu7gkiB_fX18eSC5AxT7EAP9jAVWzjDps6VToW3dRIGsmjGV5kTipbrYiO&state=%7B%22renderingId%22%3A97988%7D 204 0 - 0.195 ms
GET /forest/authentication/callback?code=j4WLQoFu7gkiB_fX18eSC5AxT7EAP9jAVWzjDps6VToW3dRIGsmjGV5kTipbrYiO&state=%7B%22renderingId%22%3A97988%7D 200 484 - 2146.256 ms
Executing (default): SELECT "id", "session_key" AS "sessionKey", "session_data" AS "sessionData", "expire_date" AS "expireDate" FROM "public"."django_session" AS "djangoSession" LIMIT 15 OFFSET 0;
Executing (default): SELECT count(*) AS "count" FROM "public"."django_session" AS "djangoSession";
[forest] 🌳🌳🌳  Unexpected error: column "id" does not exist
{
  "name": "SequelizeDatabaseError",
  "parent": {
    "length": 101,
    "name": "error",
    "severity": "ERROR",
    "code": "42703",
    "position": "8",
    "file": "parse_relation.c",
    "line": "3359",
    "routine": "errorMissingColumn",
    "sql": "SELECT \"id\", \"session_key\" AS \"sessionKey\", \"session_data\" AS \"sessionData\", \"expire_date\" AS \"expireDate\" FROM \"public\".\"django_session\" AS \"djangoSession\" LIMIT 15 OFFSET 0;"
  },
  "original": {
    "length": 101,
    "name": "error",
    "severity": "ERROR",
    "code": "42703",
    "position": "8",
    "file": "parse_relation.c",
    "line": "3359",
    "routine": "errorMissingColumn",
    "sql": "SELECT \"id\", \"session_key\" AS \"sessionKey\", \"session_data\" AS \"sessionData\", \"expire_date\" AS \"expireDate\" FROM \"public\".\"django_session\" AS \"djangoSession\" LIMIT 15 OFFSET 0;"
  },
  "sql": "SELECT \"id\", \"session_key\" AS \"sessionKey\", \"session_data\" AS \"sessionData\", \"expire_date\" AS \"expireDate\" FROM \"public\".\"django_session\" AS \"djangoSession\" LIMIT 15 OFFSET 0;",
  "stack": "SequelizeDatabaseError: column \"id\" does not exist\n    at Query.formatError (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/lib/dialects/postgres/query.js:354:16)\n    at /home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/lib/dialects/postgres/query.js:71:18\n    at tryCatcher (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)\n    at Promise._settlePromise (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)\n    at Promise._settlePromise0 (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)\n    at Promise._settlePromises (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:725:18)\n    at _drainQueueStep (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)\n    at _drainQueue (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)\n    at Async._drainQueues (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)\n    at Immediate.Async.drainQueues [as _onImmediate] (/home/flavio/Documents/vital-intelligence/vi-utilities-webadmin/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)\n    at processImmediate (internal/timers.js:464:21)"
}
GET /forest/djangoSession?timezone=America%2FSao_Paulo&fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey%2Cid&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0 500 99 - 164.298 ms
GET /forest/djangoSession/count?fields%5BdjangoSession%5D=expireDate%2CsessionData%2CsessionKey%2Cid&searchExtended=0&timezone=America%2FSao_Paulo 304 - - 158.445 ms

This is correct, because it is a Django table, which does not contain a field called id.

The primary key for this table is the session_key. The solution, in fact, was adding the primaryKey field in sessionKey field configuration on the model.

// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
  const { Sequelize } = sequelize;
  // This section contains the fields of your model, mapped to your table's columns.
  // Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
  const DjangoSession = sequelize.define('djangoSession', {
    sessionKey: {
      type: DataTypes.STRING,
      allowNull: false,
      primaryKey: true
    },
    sessionData: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    expireDate: {
      type: DataTypes.DATE,
      allowNull: false,
    },
  }, {
    tableName: 'django_session',
    underscored: true,
    timestamps: false,
    schema: process.env.DATABASE_SCHEMA,
  });
  DjangoSession.removeAttribute('id');
  // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
  DjangoSession.associate = (models) => {
  };

  return DjangoSession;
};

Thank you very much for all your support.

Best regards,

Flavio

Good to know it works now :raised_hands:

Are all your collections working now?

We are almost there …

Last week I tried to setup an empty database to ForestAdmin, using the same database structure, but another db (a local one).

The integration with ForestAdmin was straighforward. It worked, but with no data.

Now, with these last tickets, I made a test: I replaced the models directory from the empty setup to this one, with available data, and these issues we were discussing does not happen anymore.

But I cannot see all the models. Here is what I have on ForestAdmin:

And here the available models on the agent:

Is there any place that must be set in order the other models be loaded on the web too?

Best regards,

Flavio

My guess is that theses collections are just hidden.

You could check by:

  • Verifying that theses collections are in the file named .forestadmin-schema.json in your forest backend.
  • If that’s the case, click on the paintbrush icon on the top right to go in “Layout mode”, you should be able to manually display theses collections.

If they aren’t in your .forestadmin-schema.json, then the issue is located elsewhere.

Just let me know :pray:

Hello @jeffladiray ,

That was it. It was only hidden.

I could enable it and now I believe that I can keep going.

Thank you very much for your support.

Best regards,

Flavio

2 Likes