Open
Description
Description of the issue
The patch remove_implicit_primary_key fails in postgresql.
The "name" column is a primary key, so postgresql seems to refuse to alter it.
Here is the log file :
File "/home/britlog/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 189, in execute_patch
_patch()
patchmodule = 'frappe.patches.v15_0.remove_implicit_primary_key'
method = None
methodargs = None
has_patch_file = True
patch = 'frappe.patches.v15_0.remove_implicit_primary_key.execute'
docstring = "\n\tFew doctypes had int PKs even though schema didn't mention them, this requires detecting it\n\t\tat runtime which is prone to bugs and adds unnecessary overhead.\n\n\t\tThis patch converts them back to varchar.\n"
_patch = <function execute at 0x7f2661754860>
start_time = 6583.769993869
File "/home/britlog/frappe-bench/apps/frappe/frappe/patches/v15_0/remove_implicit_primary_key.py", line 34, in execute
frappe.db.change_column_type(
doctype = 'Version'
File "/home/britlog/frappe-bench/apps/frappe/frappe/database/postgres/database.py", line 261, in change_column_type
return self.sql_ddl(
self = <frappe.database.postgres.database.PostgresDatabase object at 0x7f2663ebc990>
doctype = 'Version'
column = 'name'
type = 'varchar(140)'
nullable = True
use_cast = False
table_name = 'tabVersion'
null_constraint = 'DROP NOT NULL'
using_cast = ''
File "/home/britlog/frappe-bench/apps/frappe/frappe/database/database.py", line 370, in sql_ddl
self.sql(query, debug=debug)
self = <frappe.database.postgres.database.PostgresDatabase object at 0x7f2663ebc990>
query = 'ALTER TABLE "tabVersion"\n\t\t\t\tALTER COLUMN "name" TYPE varchar(140) ,\n\t\t\t\tALTER COLUMN "name" DROP NOT NULL'
debug = False
File "/home/britlog/frappe-bench/apps/frappe/frappe/database/postgres/database.py", line 203, in sql
return super().sql(modify_query(query), modify_values(values), *args, **kwargs)
self = <frappe.database.postgres.database.PostgresDatabase object at 0x7f2663ebc990>
query = 'ALTER TABLE "tabVersion"\n\t\t\t\tALTER COLUMN "name" TYPE varchar(140) ,\n\t\t\t\tALTER COLUMN "name" DROP NOT NULL'
values = <object object at 0x7f2667585810>
args = ()
kwargs = {'debug': False}
__class__ = <class 'frappe.database.postgres.database.PostgresDatabase'>
File "/home/britlog/frappe-bench/apps/frappe/frappe/database/database.py", line 217, in sql
self._cursor.execute(query, values)
self = <frappe.database.postgres.database.PostgresDatabase object at 0x7f2663ebc990>
query = 'ALTER TABLE "tabVersion"\n\t\t\t\tALTER COLUMN "name" TYPE varchar(140) ,\n\t\t\t\tALTER COLUMN "name" DROP NOT NULL'
values = None
as_dict = 0
as_list = 0
debug = False
ignore_ddl = 0
auto_commit = 0
update = None
explain = False
run = True
pluck = False
trace_id = None
psycopg2.errors.InvalidTableDefinition: column "name" is in a primary key