diff --git a/account/src/test/java/com/ning/billing/account/dao/MockAccountDao.java b/account/src/test/java/com/ning/billing/account/dao/MockAccountDao.java
index b11c327..8d10192 100644
--- a/account/src/test/java/com/ning/billing/account/dao/MockAccountDao.java
+++ b/account/src/test/java/com/ning/billing/account/dao/MockAccountDao.java
@@ -63,7 +63,7 @@ public class MockAccountDao extends MockEntityDaoBase<AccountModelDao, Account,
final Long accountRecordId = getRecordId(account.getId(), context);
final long tenantRecordId = context == null ? InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID
: context.getTenantRecordId();
- eventBus.post(new DefaultAccountCreationEvent(new DefaultAccountData(account), account.getId(), context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()));
+ eventBus.post(new DefaultAccountCreationEvent(new DefaultAccountData(account), account.getId(), accountRecordId, tenantRecordId, UUID.randomUUID()));
} catch (final EventBusException ex) {
Assert.fail(ex.toString());
}
@@ -78,7 +78,7 @@ public class MockAccountDao extends MockEntityDaoBase<AccountModelDao, Account,
final long tenantRecordId = context == null ? InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID
: context.getTenantRecordId();
final AccountChangeInternalEvent changeEvent = new DefaultAccountChangeEvent(account.getId(), currentAccount, account,
- context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()
+ accountRecordId, tenantRecordId, UUID.randomUUID()
);
if (changeEvent.hasChanges()) {
try {
diff --git a/beatrix/src/main/resources/com/ning/billing/beatrix/ddl.sql b/beatrix/src/main/resources/com/ning/billing/beatrix/ddl.sql
index 5a5d608..ff53553 100644
--- a/beatrix/src/main/resources/com/ning/billing/beatrix/ddl.sql
+++ b/beatrix/src/main/resources/com/ning/billing/beatrix/ddl.sql
@@ -11,23 +11,26 @@ CREATE TABLE bus_ext_events (
processing_owner char(50) DEFAULT NULL,
processing_available_date datetime DEFAULT NULL,
processing_state varchar(14) DEFAULT 'AVAILABLE',
- account_record_id int(11) unsigned default null,
- tenant_record_id int(11) unsigned default null,
+ search_key1 int(11) unsigned default null,
+ search_key2 int(11) unsigned default null,
PRIMARY KEY(record_id)
);
-CREATE INDEX `idx_ext_bus_where` ON bus_ext_events (`processing_state`,`processing_owner`,`processing_available_date`);
-CREATE INDEX ext_bus_events_tenant_account_record_id ON bus_ext_events(tenant_record_id, account_record_id);
+CREATE INDEX `idx_bus_ext_where` ON bus_ext_events (`processing_state`,`processing_owner`,`processing_available_date`);
+CREATE INDEX bus_ext_events_tenant_account_record_id ON bus_ext_events(search_key2, search_key1);
-
-
-DROP TABLE IF EXISTS claimed_bus_ext_events;
-CREATE TABLE claimed_bus_ext_events (
+DROP TABLE IF EXISTS bus_ext_events_history;
+CREATE TABLE bus_ext_events_history (
record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
- owner_id varchar(64) NOT NULL,
- claimed_date datetime NOT NULL,
- bus_event_id char(36) NOT NULL,
- account_record_id int(11) unsigned DEFAULT NULL,
- tenant_record_id int(11) unsigned DEFAULT NULL,
+ class_name varchar(128) NOT NULL,
+ event_json varchar(2048) NOT NULL,
+ user_token char(36),
+ created_date datetime NOT NULL,
+ creating_owner char(50) NOT NULL,
+ processing_owner char(50) DEFAULT NULL,
+ processing_available_date datetime DEFAULT NULL,
+ processing_state varchar(14) DEFAULT 'AVAILABLE',
+ search_key1 int(11) unsigned default null,
+ search_key2 int(11) unsigned default null,
PRIMARY KEY(record_id)
);
-CREATE INDEX claimed_bus_ext_events_tenant_account_record_id ON claimed_bus_ext_events(tenant_record_id, account_record_id);
+
diff --git a/util/src/main/resources/com/ning/billing/util/ddl.sql b/util/src/main/resources/com/ning/billing/util/ddl.sql
index 659a47a..d0b48cd 100644
--- a/util/src/main/resources/com/ning/billing/util/ddl.sql
+++ b/util/src/main/resources/com/ning/billing/util/ddl.sql
@@ -124,43 +124,6 @@ CREATE INDEX tag_history_target_record_id ON tag_history(target_record_id);
CREATE INDEX tag_history_by_object ON tags(object_id);
CREATE INDEX tag_history_tenant_account_record_id ON tag_history(tenant_record_id, account_record_id);
-DROP TABLE IF EXISTS notifications;
-CREATE TABLE notifications (
- record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
- id char(36) NOT NULL,
- created_date datetime NOT NULL,
- class_name varchar(256) NOT NULL,
- notification_key varchar(2048) NOT NULL,
- user_token char(36),
- future_user_token char(36),
- creating_owner char(50) NOT NULL,
- effective_date datetime NOT NULL,
- queue_name char(64) NOT NULL,
- processing_owner char(50) DEFAULT NULL,
- processing_available_date datetime DEFAULT NULL,
- processing_state varchar(14) DEFAULT 'AVAILABLE',
- account_record_id int(11) unsigned default null,
- tenant_record_id int(11) unsigned default null,
- PRIMARY KEY(record_id)
-);
-CREATE UNIQUE INDEX notifications_id ON notifications(id);
-CREATE INDEX `idx_comp_where` ON notifications (`effective_date`, `processing_state`,`processing_owner`,`processing_available_date`);
-CREATE INDEX `idx_update` ON notifications (`processing_state`,`processing_owner`,`processing_available_date`);
-CREATE INDEX `idx_get_ready` ON notifications (`effective_date`,`created_date`,`id`);
-CREATE INDEX notifications_tenant_account_record_id ON notifications(tenant_record_id, account_record_id);
-
-DROP TABLE IF EXISTS claimed_notifications;
-CREATE TABLE claimed_notifications (
- record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
- owner_id varchar(64) NOT NULL,
- claimed_date datetime NOT NULL,
- notification_id char(36) NOT NULL,
- account_record_id int(11) unsigned default null,
- tenant_record_id int(11) unsigned default null,
- PRIMARY KEY(record_id)
-);
-CREATE INDEX claimed_notifications_tenant_account_record_id ON claimed_notifications(tenant_record_id, account_record_id);
-
DROP TABLE IF EXISTS audit_log;
/*! SET storage_engine=INNODB */;
@@ -185,32 +148,79 @@ CREATE INDEX audit_log_tenant_account_record_id ON audit_log(tenant_record_id, a
CREATE INDEX audit_log_via_history ON audit_log(target_record_id, table_name, tenant_record_id);
-DROP TABLE IF EXISTS bus_events;
-CREATE TABLE bus_events (
- record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
- class_name varchar(128) NOT NULL,
- event_json varchar(2048) NOT NULL,
- user_token char(36),
- created_date datetime NOT NULL,
- creating_owner char(50) NOT NULL,
- processing_owner char(50) DEFAULT NULL,
- processing_available_date datetime DEFAULT NULL,
- processing_state varchar(14) DEFAULT 'AVAILABLE',
- account_record_id int(11) unsigned default null,
- tenant_record_id int(11) unsigned default null,
- PRIMARY KEY(record_id)
-);
-CREATE INDEX `idx_bus_where` ON bus_events (`processing_state`,`processing_owner`,`processing_available_date`);
-CREATE INDEX bus_events_tenant_account_record_id ON bus_events(tenant_record_id, account_record_id);
-DROP TABLE IF EXISTS claimed_bus_events;
-CREATE TABLE claimed_bus_events (
- record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
- owner_id varchar(64) NOT NULL,
- claimed_date datetime NOT NULL,
- bus_event_id char(36) NOT NULL,
- account_record_id int(11) unsigned default null,
- tenant_record_id int(11) unsigned default null,
- PRIMARY KEY(record_id)
-);
-CREATE INDEX claimed_bus_events_tenant_account_record_id ON claimed_bus_events(tenant_record_id, account_record_id);
+DROP TABLE IF EXISTS notifications;
+ CREATE TABLE notifications (
+ record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
+ class_name varchar(256) NOT NULL,
+ event_json varchar(2048) NOT NULL,
+ user_token char(36),
+ created_date datetime NOT NULL,
+ creating_owner char(50) NOT NULL,
+ processing_owner char(50) DEFAULT NULL,
+ processing_available_date datetime DEFAULT NULL,
+ processing_state varchar(14) DEFAULT 'AVAILABLE',
+ search_key1 int(11) unsigned default null,
+ search_key2 int(11) unsigned default null,
+ queue_name char(64) NOT NULL,
+ effective_date datetime NOT NULL,
+ future_user_token char(36),
+ PRIMARY KEY(record_id)
+ );
+ CREATE INDEX `idx_comp_where` ON notifications (`effective_date`, `processing_state`,`processing_owner`,`processing_available_date`);
+ CREATE INDEX `idx_update` ON notifications (`processing_state`,`processing_owner`,`processing_available_date`);
+ CREATE INDEX `idx_get_ready` ON notifications (`effective_date`,`created_date`);
+ CREATE INDEX notifications_tenant_account_record_id ON notifications(search_key2, search_key1);
+
+ DROP TABLE IF EXISTS notifications_history;
+ CREATE TABLE notifications_history (
+ record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
+ class_name varchar(256) NOT NULL,
+ event_json varchar(2048) NOT NULL,
+ user_token char(36),
+ created_date datetime NOT NULL,
+ creating_owner char(50) NOT NULL,
+ processing_owner char(50) DEFAULT NULL,
+ processing_available_date datetime DEFAULT NULL,
+ processing_state varchar(14) DEFAULT 'AVAILABLE',
+ search_key1 int(11) unsigned default null,
+ search_key2 int(11) unsigned default null,
+ queue_name char(64) NOT NULL,
+ effective_date datetime NOT NULL,
+ future_user_token char(36),
+ PRIMARY KEY(record_id)
+ );
+
+ DROP TABLE IF EXISTS bus_events;
+ CREATE TABLE bus_events (
+ record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
+ class_name varchar(128) NOT NULL,
+ event_json varchar(2048) NOT NULL,
+ user_token char(36),
+ created_date datetime NOT NULL,
+ creating_owner char(50) NOT NULL,
+ processing_owner char(50) DEFAULT NULL,
+ processing_available_date datetime DEFAULT NULL,
+ processing_state varchar(14) DEFAULT 'AVAILABLE',
+ search_key1 int(11) unsigned default null,
+ search_key2 int(11) unsigned default null,
+ PRIMARY KEY(record_id)
+ );
+ CREATE INDEX `idx_bus_where` ON bus_events (`processing_state`,`processing_owner`,`processing_available_date`);
+ CREATE INDEX bus_events_tenant_account_record_id ON bus_events(search_key2, search_key1);
+
+ DROP TABLE IF EXISTS bus_events_history;
+ CREATE TABLE bus_events_history (
+ record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
+ class_name varchar(128) NOT NULL,
+ event_json varchar(2048) NOT NULL,
+ user_token char(36),
+ created_date datetime NOT NULL,
+ creating_owner char(50) NOT NULL,
+ processing_owner char(50) DEFAULT NULL,
+ processing_available_date datetime DEFAULT NULL,
+ processing_state varchar(14) DEFAULT 'AVAILABLE',
+ search_key1 int(11) unsigned default null,
+ search_key2 int(11) unsigned default null,
+ PRIMARY KEY(record_id)
+ );