{"action":"created","issue":{"url":"https://api.github.com/repos/modoboa/modoboa-amavis/issues/5","labels_url":"https://api.github.com/repos/modoboa/modoboa-amavis/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/modoboa/modoboa-amavis/issues/5/comments","events_url":"https://api.github.com/repos/modoboa/modoboa-amavis/issues/5/events","html_url":"https://github.com/modoboa/modoboa-amavis/issues/5","id":72618315,"number":5,"title":"amavis extension does not manage policies in a way compatible with amavisd-new's own documentation","user":{"login":"tonioo","id":531694,"avatar_url":"https://avatars.githubusercontent.com/u/531694?v=3","gravatar_id":"","url":"https://api.github.com/users/tonioo","html_url":"https://github.com/tonioo","followers_url":"https://api.github.com/users/tonioo/followers","following_url":"https://api.github.com/users/tonioo/following{/other_user}","gists_url":"https://api.github.com/users/tonioo/gists{/gist_id}","starred_url":"https://api.github.com/users/tonioo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonioo/subscriptions","organizations_url":"https://api.github.com/users/tonioo/orgs","repos_url":"https://api.github.com/users/tonioo/repos","events_url":"https://api.github.com/users/tonioo/events{/privacy}","received_events_url":"https://api.github.com/users/tonioo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/modoboa/modoboa-amavis/labels/Amavis","name":"Amavis","color":"ededed"},{"url":"https://api.github.com/repos/modoboa/modoboa-amavis/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"tonioo","id":531694,"avatar_url":"https://avatars.githubusercontent.com/u/531694?v=3","gravatar_id":"","url":"https://api.github.com/users/tonioo","html_url":"https://github.com/tonioo","followers_url":"https://api.github.com/users/tonioo/followers","following_url":"https://api.github.com/users/tonioo/following{/other_user}","gists_url":"https://api.github.com/users/tonioo/gists{/gist_id}","starred_url":"https://api.github.com/users/tonioo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonioo/subscriptions","organizations_url":"https://api.github.com/users/tonioo/orgs","repos_url":"https://api.github.com/users/tonioo/repos","events_url":"https://api.github.com/users/tonioo/events{/privacy}","received_events_url":"https://api.github.com/users/tonioo/received_events","type":"User","site_admin":false},"milestone":null,"comments":13,"created_at":"2015-05-02T09:20:40Z","updated_at":"2015-05-02T09:20:49Z","closed_at":null,"body":"_From @tonioo on December 4, 2013 15:44_\n\n**Originally created by Louis-Dominique Dubeau on 2012-09-06T12:34:53Z**\n\nModoboa version: 0.9.2\r\nAmavisd-new version: 2.7.1\r\n\r\nThe documentation regarding SQL usage provided with amavisd-new suggests that multiple records in the users table should point to the same record in the policy table. Said documentation is here:\r\n\r\nhttp://www.ijs.si/software/amavisd/README.sql-mysql.txt\r\n\r\nRecipes helping sysadmins setting up amavisd-new for SQL suggest populating the policy table with useful values. Here is a typical example:\r\n\r\nINSERT INTO policy (id, policy_name,\r\n  virus_lover, spam_lover, banned_files_lover, bad_header_lover,\r\n  bypass_virus_checks, bypass_spam_checks,\r\n  bypass_banned_checks, bypass_header_checks, spam_modifies_subj,\r\n  spam_tag_level, spam_tag2_level, spam_kill_level) VALUES\r\n  (1, 'Non-paying',    'N','N','N','N', 'Y','Y','Y','N', 'Y', 3.0,   7, 10),\r\n  (2, 'Uncensored',    'Y','Y','Y','Y', 'N','N','N','N', 'N', 3.0, 999, 999),\r\n  (3, 'Wants all spam','N','Y','N','N', 'N','N','N','N', 'Y', 3.0, 999, 999),\r\n  (4, 'Wants viruses', 'Y','N','Y','Y', 'N','N','N','N', 'Y', 3.0, 6.9, 6.9),\r\n  (5, 'Normal',        'N','N','N','N', 'N','N','N','N', 'Y', -999, 6.9, 9.0),\r\n  (6, 'Trigger happy', 'N','N','N','N', 'N','N','N','N', 'Y', 3.0,   5, 5),\r\n  (7, 'Permissive',    'N','N','N','Y', 'N','N','N','N', 'Y', 3.0,  10, 20);\r\n\r\nIf an administrator manages multiple domains and all these domains require a policy corresponding to the \"Normal\" policy, then the administrator would have all of these domains point to the \"Normal\" policy record. E.g.:\r\n\r\n- @foo.com in the table users points to policy \"Normal\" (id 5) in the table policy.\r\n- @bar.com in the table users points to policy \"Normal\" (id 5) in the table policy.\r\n\r\nPresumably, the idea is that if administrator decides to change what \"Normal\" means, then he does not have to go through all domains one by one. He just changes the \"Normal\" record in the policy table.\r\n\r\nHowever, assuming the setup above, let's assume that an administrator adds Modoboa to his setup and uses Modoboa to alter the policy of foo.com.\r\n\r\nExpected result: Only the settings of foo.com should change.\r\n\r\nActual result: Modoboa also *silently* alters the settings of bar.com. There is nothing on screen indicating that what Modoboa is changing has an effect greater than foo.com. This is because Modoboa modifies the settings for foo.com by modifying the \"Normal\" record in the policy table. Thus, everything pointing to \"Normal\" is altered.\r\n\r\n(I've considered whether filing this as a bug or a feature request. I've decided on a bug since the current behavior yields unexpected results.)\r\n\r\nAs an administrator what I would ideally want the amavis extension to do is handle the two tables --- users and policy --- in a way which is compatible with what the developers of amavisd-new intended. I should be able to:\r\n\r\n- Create new policies. Delete policies. Edit policies. \"Policies\" here means \"records in the policy table.\"\r\n- Change the relationship between a user and a policy (e.g. get foo.com to use the 'Trigger happy' policy rather than 'Normal'.)\r\n\n\n_Copied from original issue: tonioo/modoboa#302_"},"comment":{"url":"https://api.github.com/repos/modoboa/modoboa-amavis/issues/comments/98338396","html_url":"https://github.com/modoboa/modoboa-amavis/issues/5#issuecomment-98338396","issue_url":"https://api.github.com/repos/modoboa/modoboa-amavis/issues/5","id":98338396,"user":{"login":"tonioo","id":531694,"avatar_url":"https://avatars.githubusercontent.com/u/531694?v=3","gravatar_id":"","url":"https://api.github.com/users/tonioo","html_url":"https://github.com/tonioo","followers_url":"https://api.github.com/users/tonioo/followers","following_url":"https://api.github.com/users/tonioo/following{/other_user}","gists_url":"https://api.github.com/users/tonioo/gists{/gist_id}","starred_url":"https://api.github.com/users/tonioo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonioo/subscriptions","organizations_url":"https://api.github.com/users/tonioo/orgs","repos_url":"https://api.github.com/users/tonioo/repos","events_url":"https://api.github.com/users/tonioo/events{/privacy}","received_events_url":"https://api.github.com/users/tonioo/received_events","type":"User","site_admin":false},"created_at":"2015-05-02T09:20:49Z","updated_at":"2015-05-02T09:20:49Z","body":"**Posted by Mike C on 2013-01-02T15:43:49Z**\n\n\r\nSorry, maybe this is more readable:\r\n\r\n@python26 manage.py syncdb --migrate\r\nSyncing...\r\nCreating tables ...\r\nInstalling custom SQL ...\r\nInstalling indexes ...\r\nInstalled 0 object(s) from 0 fixture(s)\r\nMigrating...\r\nRunning migrations for lib:\r\n- Nothing to migrate.\r\n - Loading initial data for lib.\r\nInstalled 0 object(s) from 0 fixture(s)\r\nRunning migrations for admin:\r\n- Nothing to migrate.\r\n - Loading initial data for admin.\r\nInstalled 2 object(s) from 1 fixture(s)\r\nRunning migrations for limits:\r\n- Nothing to migrate.\r\n - Loading initial data for limits.\r\nInstalled 0 object(s) from 0 fixture(s)\r\nRunning migrations for postfix_autoreply:\r\n- Nothing to migrate.\r\n - Loading initial data for postfix_autoreply.\r\nInstalled 0 object(s) from 0 fixture(s)\r\nRunning migrations for amavis:\r\n - Migrating forwards to 0002_create_records.\r\n > amavis:0002_create_records\r\n - Migration 'amavis:0002_create_records' is marked for no-dry-run.\r\n ! Error found during real run of migration! Aborting.\r\n! Since you have a database that does not support running\r\n ! schema-altering statements in transactions, we have had\r\n ! to leave it in an interim state between migrations.\r\n\r\n! You might be able to recover with: (migration cannot be dry-run; cannot discover commands)\r\n ! The South developers regret this has happened, and would\r\n ! like to gently persuade you to consider a slightly\r\n ! easier-to-deal-with DBMS (one that supports DDL transactions)\r\n ! NOTE: The error which caused the migration to fail is further up.\r\nError in migration: amavis:0002_create_records\r\nTraceback (most recent call last):\r\n File \"manage.py\", line 10, in <module>\r\n execute_from_command_line(sys.argv)\r\n File \"/usr/lib/python2.6/site-packages/django/core/management/__init__.py\", line 443, in execute_from_command_line\r\n utility.execute()\r\n File \"/usr/lib/python2.6/site-packages/django/core/management/__init__.py\", line 382, in execute\r\n self.fetch_command(subcommand).run_from_argv(self.argv)\r\n File \"/usr/lib/python2.6/site-packages/django/core/management/base.py\", line 196, in run_from_argv\r\n self.execute(args, **options.__dict__)\r\n File \"/usr/lib/python2.6/site-packages/django/core/management/base.py\", line 232, in execute\r\n output = self.handle(*args, **options)\r\n File \"/usr/lib/python2.6/site-packages/django/core/management/base.py\", line 371, in handle\r\n return self.handle_noargs(*options)\r\n File \"/usr/lib/python2.6/site-packages/south/management/commands/syncdb.py\", line 99, in handle_noargs\r\n management.call_command('migrate', *options)\r\n File \"/usr/lib/python2.6/site-packages/django/core/management/__init__.py\", line 150, in call_command\r\n return klass.execute(*args, **defaults)\r\n File \"/usr/lib/python2.6/site-packages/django/core/management/base.py\", line 232, in execute\r\n output = self.handle(*args, **options)\r\n File \"/usr/lib/python2.6/site-packages/south/management/commands/migrate.py\", line 108, in handle\r\n ignore_ghosts = ignore_ghosts,\r\n File \"/usr/lib/python2.6/site-packages/south/migration/__init__.py\", line 213, in migrate_app\r\n success = migrator.migrate_many(target, workplan, database)\r\n File \"/usr/lib/python2.6/site-packages/south/migration/migrators.py\", line 235, in migrate_many\r\n result = migrator.__class__.migrate_many(migrator, target, migrations, database)\r\n File \"/usr/lib/python2.6/site-packages/south/migration/migrators.py\", line 310, in migrate_many\r\n result = self.migrate(migration, database)\r\n File \"/usr/lib/python2.6/site-packages/south/migration/migrators.py\", line 133, in migrate\r\n result = self.run(migration)\r\n File \"/usr/lib/python2.6/site-packages/south/migration/migrators.py\", line 107, in run\r\n return self.run_migration(migration)\r\n File \"/usr/lib/python2.6/site-packages/south/migration/migrators.py\", line 81, in run_migration\r\n migration_function()\r\n File \"/usr/lib/python2.6/site-packages/south/migration/migrators.py\", line 57, in <lambda>\r\n return (lambda: direction(orm))\r\n File \"/usr/lib/python2.6/site-packages/modoboa/extensions/amavis/migrations/0002_create_records.py\", line 15, in forwards\r\n spam_modifies_subj=None)\r\n File \"/usr/lib/python2.6/site-packages/django/db/models/manager.py\", line 137, in create\r\n return self.get_query_set().create(*kwargs)\r\n File \"/usr/lib/python2.6/site-packages/django/db/models/query.py\", line 377, in create\r\n obj.save(force_insert=True, using=self.db)\r\n File \"/usr/lib/python2.6/site-packages/django/db/models/base.py\", line 463, in save\r\n self.save_base(using=using, force_insert=force_insert, force_update=force_update)\r\n File \"/usr/lib/python2.6/site-packages/django/db/models/base.py\", line 551, in save_base\r\n result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)\r\n File \"/usr/lib/python2.6/site-packages/django/db/models/manager.py\", line 203, in _insert\r\n return insert_query(self.model, objs, fields, **kwargs)\r\n File \"/usr/lib/python2.6/site-packages/django/db/models/query.py\", line 1593, in insert_query\r\n return query.get_compiler(using=using).execute_sql(return_id)\r\n File \"/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py\", line 912, in execute_sql\r\n cursor.execute(sql, params)\r\n File \"/usr/lib/python2.6/site-packages/django/db/backends/util.py\", line 40, in execute\r\n return self.cursor.execute(sql, params)\r\n File \"/usr/lib/python2.6/site-packages/django/db/backends/mysql/base.py\", line 114, in execute\r\n return self.cursor.execute(query, args)\r\n File \"/usr/lib/python2.6/site-packages/MySQLdb/cursors.py\", line 173, in execute\r\n self.errorhandler(self, exc, value)\r\n File \"/usr/lib/python2.6/site-packages/MySQLdb/connections.py\", line 36, in defaulterrorhandler\r\n raise errorclass, errorvalue\r\ndjango.db.utils.DatabaseError: (1054, \"Unknown column 'sa_username' in 'field list'\") <---- I notice this now... maybe this is the problem!?\r\n@"}}