How to use cleanup_m2m_pivot method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...58 (table, key_name, field, destination_table))59def drop_foreign_key_constraint(manager, table, field):60 key_name = foreign_key_name(table, field)61 manager.execute('ALTER TABLE %s DROP FOREIGN KEY %s' % (table, key_name))62def cleanup_m2m_pivot(manager, pivot_table, first_field, first_table,63 second_field, second_table, create_unique):64 delete_duplicates(manager, pivot_table, first_field, second_field)65 delete_invalid_foriegn_keys(manager, pivot_table, first_field, first_table)66 delete_invalid_foriegn_keys(manager, pivot_table, second_field,67 second_table)68 if create_unique:69 # first field is the more commonly used one, so we'll replace the70 # less-commonly-used index with the larger unique index71 create_unique_index(manager, pivot_table, second_field, first_field)72 create_foreign_key_constraint(manager, pivot_table, first_field,73 first_table)74 create_foreign_key_constraint(manager, pivot_table, second_field,75 second_table)76def reverse_cleanup_m2m_pivot(manager, pivot_table, first_field, second_field,77 drop_unique):78 drop_foreign_key_constraint(manager, pivot_table, second_field)79 drop_foreign_key_constraint(manager, pivot_table, first_field)80 if drop_unique:81 drop_unique_index(manager, pivot_table, second_field)82TABLES = (83 ('hosts_labels', 'host_id', 'hosts', 'label_id', 'labels', True),84 ('acl_groups_hosts', 'host_id', 'hosts', 'aclgroup_id', 'acl_groups',85 True),86 ('acl_groups_users', 'user_id', 'users', 'aclgroup_id', 'acl_groups',87 True),88 ('autotests_dependency_labels', 'test_id', 'autotests', 'label_id',89 'labels', False),90 ('jobs_dependency_labels', 'job_id', 'jobs', 'label_id', 'labels',91 False),92 ('ineligible_host_queues', 'job_id', 'jobs', 'host_id', 'hosts', True),93 )94def migrate_up(manager):95 for (table, first_field, first_table, second_field, second_table,96 create_unique) in TABLES:97 cleanup_m2m_pivot(manager, table, first_field, first_table,98 second_field, second_table, create_unique)99def migrate_down(manager):100 for (table, first_field, first_table, second_field, second_table,101 drop_unique) in reversed(TABLES):102 reverse_cleanup_m2m_pivot(manager, table, first_field, second_field,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?