# psycopg2.errors.UndefinedTable: relation "model\_id\_seq" does not exist while migration of my module

**URL:** https://discuss.tryton.org/t/psycopg2-errors-undefinedtable-relation-model-id-seq-does-not-exist-while-migration-of-my-module/6059
**Category:** Developer
**Created:** [April 5, 2023, 2:05pm UTC](https://discuss.tryton.org/t/psycopg2-errors-undefinedtable-relation-model-id-seq-does-not-exist-while-migration-of-my-module/6059 "2023-04-05T14:05:07Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![danhedaiat](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/danhedaiat/32/2262_2.png) [@danhedaiat](https://discuss.tryton.org/u/danhedaiat)
#### Post date: [April 5, 2023, 2:05pm UTC](https://discuss.tryton.org/t/psycopg2-errors-undefinedtable-relation-model-id-seq-does-not-exist-while-migration-of-my-module/6059/1 "2023-04-05T14:05:08Z")

</div>

hi, im try to use `trytond-admin -d test -u z_nurse_call` command, to add my own module to gnuhealth and this is my module:

```auto
class NurseCall(ModelSQL, ModelView):
	"Nurse Call"
	__name__ = "arnika.nurseCall"
	__rec_name = "name"
	name = fields.Many2One('gnuhealth.patient', 'Patient')
	date = fields.DateTime('Date')
	bed = fields.Many2One('gnuhealth.hospital.bed', 'Hospital Bed',)
	health_professional = fields.Many2One('gnuhealth.healthprofessional','Health Professional', readonly=True)
	
	@classmethod
	def __setup__ (cls):
	   super(). __setup__ ()
	   t = cls. __table__ ()
	   cls._sql_constraints = [
	       ('name_uniq', Unique(t, t.name), 'The Name must be unique !'),]

```

and i get this error :

```auto
3636 140440737433408 [2023-04-05 13:21:46,503] WARNING py.warnings /usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, imp, stat

Traceback (most recent call last):
  File "gnuhealth/tryton/server/trytond-6.0.27/bin/trytond-admin", line 23, in <module>
    admin.run(options)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/admin.py", line 53, in run
    pool.init(update=options.update, lang=list(lang),
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/pool.py", line 164, in init
    restart = not load_modules(
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/modules/ __init__.py", line 438, in load_modules
    _load_modules(update)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/modules/ __init__.py", line 406, in _load_modules
    load_module_graph(graph, pool, update, lang)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/modules/ __init__.py", line 238, in load_module_graph
    cls. __register__ (module)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/model/modelsql.py", line 228, in __register__
    table = cls. __table_handler__ (module_name)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/model/modelsql.py", line 212, in __table_handler__
    return backend.TableHandler(cls, module_name, history=history)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/backend/postgresql/table.py", line 56, in __init__
    cursor.execute(
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-6.0.27/trytond/backend/postgresql/database.py", line 74, in execute
    cursor.execute(self, sql, args)
psycopg2.errors.UndefinedTable: relation "arnika_nursecall_id_seq" does not exist

```

any help make me happy .

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [April 5, 2023, 2:22pm UTC](https://discuss.tryton.org/t/psycopg2-errors-undefinedtable-relation-model-id-seq-does-not-exist-while-migration-of-my-module/6059/2 "2023-04-05T14:22:14Z")

</div>

It may be linked to the CamelCase name. But normally we do not remove the case on the table name (nor sequence name). Also before the failing code, there is a test about the existence of the sequence.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [April 5, 2023, 8:17pm UTC](https://discuss.tryton.org/t/psycopg2-errors-undefinedtable-relation-model-id-seq-does-not-exist-while-migration-of-my-module/6059/3 "2023-04-05T20:17:14Z")

</div>

Can you elaborate on what was the problem and if we should fix something?

---

<div class="post-metadata">

### Author: ![danhedaiat](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/danhedaiat/32/2262_2.png) [@danhedaiat](https://discuss.tryton.org/u/danhedaiat)
#### Post date: [April 8, 2023, 5:24am UTC](https://discuss.tryton.org/t/psycopg2-errors-undefinedtable-relation-model-id-seq-does-not-exist-while-migration-of-my-module/6059/4 "2023-04-08T05:24:25Z")

</div>

yep i fix that , as you said its for CamelCase name. thanks to you

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [April 8, 2023, 9:08am UTC](https://discuss.tryton.org/t/psycopg2-errors-undefinedtable-relation-model-id-seq-does-not-exist-while-migration-of-my-module/6059/5 "2023-04-08T09:08:28Z")

</div>

Indeed there is a bug that prevent Tryton to manage correctly sequences with different cases: [PostgreSQL sequence functions fails with CamelCase names (#12194) · Issues · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/issues/12194)

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [May 8, 2023, 9:09am UTC](https://discuss.tryton.org/t/psycopg2-errors-undefinedtable-relation-model-id-seq-does-not-exist-while-migration-of-my-module/6059/6 "2023-05-08T09:09:05Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
