diff --git a/app/jobs/event_created_job.rb b/app/jobs/event_created_job.rb deleted file mode 100644 index fa576773..00000000 --- a/app/jobs/event_created_job.rb +++ /dev/null @@ -1,9 +0,0 @@ -class EventCreatedJob - include Sidekiq::Job - - def perform(args) - event = Event.find(args['id']) - - puts "EventCreatedJob #{event.id}" - end -end diff --git a/app/models/event.rb b/app/models/event.rb deleted file mode 100644 index 4ffa498b..00000000 --- a/app/models/event.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Event < ActiveRecord::Base - include Outboxer::Messageable - - self.inheritance_column = :_type_disabled - - attribute :created_at, default: -> { Time.current } - - belongs_to :eventable, polymorphic: true - - validates :type, presence: true - validates :eventable, presence: true - - has_outboxer_message dependent: :destroy -end diff --git a/app/models/invoice.rb b/app/models/invoice.rb deleted file mode 100644 index 21651c9e..00000000 --- a/app/models/invoice.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Invoice < ActiveRecord::Base - has_many :events, - -> { order(created_at: :asc) }, - as: :eventable -end diff --git a/db/migrate/create_events.rb b/db/migrate/create_events.rb deleted file mode 100644 index 114cb3ab..00000000 --- a/db/migrate/create_events.rb +++ /dev/null @@ -1,16 +0,0 @@ -class CreateEvents < ActiveRecord::Migration[6.1] - def up - create_table :events, force: true do |t| - t.string :type, null: false - t.jsonb :payload - - t.datetime :created_at, null: false - - t.references :eventable, polymorphic: true, null: false, index: true - end - end - - def down - drop_table :events - end -end diff --git a/db/migrate/create_invoices.rb b/db/migrate/create_invoices.rb deleted file mode 100644 index 09809319..00000000 --- a/db/migrate/create_invoices.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateInvoices < ActiveRecord::Migration[6.1] - def up - create_table :invoices, force: true do |t| - t.integer :lock_version, default: 0, null: false - - t.timestamps null: false - end - end - - def down - drop_table :invoices - end -end - diff --git a/spec/lib/outboxer/messageable_spec.rb b/spec/lib/outboxer/messageable_spec.rb deleted file mode 100644 index 9e0859e6..00000000 --- a/spec/lib/outboxer/messageable_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' - -RSpec.describe Outboxer::Messageable, type: :model do - before(:each) do - ActiveRecord::Schema.define do - create_table :events, force: true do |_t| - end - end - - class Event < ActiveRecord::Base - include Outboxer::Messageable - end - end - - after(:each) do - if ActiveRecord::Base.connection.table_exists?('events') - ActiveRecord::Migration.drop_table('events') - end - - Object.send(:remove_const, :Event) if Object.const_defined?(:Event) - end - - context 'when model created' do - let(:event) { Event.create! } - let(:outboxer_message) { event.outboxer_message } - - it 'creates outboxer message' do - expect(outboxer_message.status).to eq(Outboxer::Models::Message::Status::UNPUBLISHED) - expect(outboxer_message.messageable_type).to eq(event.class.to_s) - expect(outboxer_message.messageable_id).to eq(event.id) - expect(outboxer_message.created_at).to be_present - expect(outboxer_message.updated_at).to be_present - end - end -end diff --git a/tasks/database.rake b/tasks/database.rake index c2eca24b..a3cb3784 100644 --- a/tasks/database.rake +++ b/tasks/database.rake @@ -28,12 +28,6 @@ namespace :outboxer do db_config = Outboxer::Database.config(environment: environment) ActiveRecord::Base.establish_connection(db_config) - require_relative "../db/migrate/create_invoices" - CreateInvoices.new.up - - require_relative "../db/migrate/create_events" - CreateEvents.new.up - require_relative "../db/migrate/create_outboxer_messages" CreateOutboxerMessages.new.up