• [deleted]

  • Edited

Never mind - recovered an older database and then recreated the tables that way. Had to delete end_date and public_poll to get it to work properly though.

In case anyone needs this, here's the SQL I used

CREATE TABLE `polls` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `question` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `discussion_id` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `user_id` int(11) NOT NULL,
  `end_date` datetime DEFAULT NULL,
  `public_poll` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `poll_options` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `answer` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `poll_id` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `poll_options_poll_id_foreign` (`poll_id`),
  CONSTRAINT `poll_options_poll_id_foreign` FOREIGN KEY (`poll_id`) REFERENCES `polls` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `poll_votes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `option_id` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `poll_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `poll_votes_option_id_foreign` (`option_id`),
  KEY `poll_votes_user_id_foreign` (`user_id`),
  CONSTRAINT `poll_votes_option_id_foreign` FOREIGN KEY (`option_id`) REFERENCES `poll_options` (`id`),
  CONSTRAINT `poll_votes_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  • [deleted]

  • Edited

Still an issue it seems. Despite successfully creating tables, and enabling the extension, I can't see the poll when created ? When editing the main post, the poll is stripped completely. Database tables are also empty....

  • [deleted]

Ok - fixed. Not entirely sure what's going on, but I ended up having to drop the tables again, enable the extension (which "worked", but didn't create the tables), then recreate the tables manually in this order

Polls -> Poll_Options -> Poll_Votes

Works now, but very odd behaviour.

    • [deleted]

    Ralkage thanks. It's a great extension, but currently fiddly in terms of setup.

      [deleted] did you previously deleted some tables manually ? Extensions use migrations to keep the database in sync. If you deleted tables but not the corresponding entries in the migrations table, then the extension can't know that it needs to re-create them.

      The only safe way to remove an extension's table or column is to rollback migrations. This can be achieved by selecting "uninstall" on the extensions page, uninstalling via Bazaar or manually running the php flarum migrate:reset --extension=vendor-package extension. Sadly if any error occurs during one of those actions, the database might be left in a state requiring manual repair.

        • [deleted]

        clarkwinkelmann I did, yes - wasn't aware of the migration, but I know now 🙂

        Is this extension works fine with Flarum 0.1.0-beta.8.1? I can create poll but can't see anything in posts.

        I just encountered a problem. Check this:

        • alx replied to this.

          alx After clicking submit the changes brought to my poll didn't save. Very weird

          I am having trouble with this extension. After installing it is not showing up in het menu. Using version v0.1.0-beta.8.

            • [deleted]

            Kasper Anything in the logs ? Typically, you'd see these in Flarum Root -> Storage -> Logs

            No nothing related to the poll files. Is there suppose to be an admin menu in the administration because i do see the modal when adding a discussion. When i add the poll it works but i cannot see the results.

              It broke my freshly installed Flarum with newest version. Just said "error occured while loading this page" Needed to remove this extention.

                Keagan any errors in your logs? Please also include the output of the php flarum info command executed in the root directory of your Flarum installation 🙂

                As soon as I hit the "show votes" button it crashes the plugin.

                7ShowVotersModal.js:31 Uncaught TypeError: n.id is not a function
                at ShowVotersModal.js:31
                at Array.map (<anonymous>)
                at e.a.getUsers (ShowVotersModal.js:26)
                at ShowVotersModal.js:61
                at Array.map (<anonymous>)
                at e.a.content (ShowVotersModal.js:58)
                at e.n.view (Modal.js:46)
                at e.render (Component.js:102)
                at e.n.view (ModalManager.js:18)
                at e.render (Component.js:102)

                What should I do?

                  • [deleted]

                  Ralkage I can reproduce this also.

                  szabovalentin this looks the same as the error you posted here btw. Did you remember to clear your Flarum cache (in the admin dashboard or php flarum cache:clear in console)? Then clear your Cloudflare cache?