maestrano-connector-rails 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/jobs/maestrano/connector/rails/synchronization_job.rb +8 -0
- data/app/models/maestrano/connector/rails/concerns/entity.rb +31 -15
- data/db/migrate/20160215103120_add_name_to_id_map.rb +8 -0
- data/maestrano-connector-rails.gemspec +3 -8
- data/spec/dummy/db/schema.rb +7 -3
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/models/entity_spec.rb +20 -20
- metadata +2 -7
- data/spec/dummy/db/migrate/20160204223447_create_users.maestrano_connector_rails_engine.rb +0 -17
- data/spec/dummy/db/migrate/20160204223448_create_organizations.maestrano_connector_rails_engine.rb +0 -22
- data/spec/dummy/db/migrate/20160204223449_create_user_organization_rels.maestrano_connector_rails_engine.rb +0 -13
- data/spec/dummy/db/migrate/20160204223450_create_synchronizations.maestrano_connector_rails_engine.rb +0 -14
- data/spec/dummy/db/migrate/20160204223451_create_id_maps.maestrano_connector_rails_engine.rb +0 -19
- data/spec/dummy/db/migrate/20160205133024_add_sync_enabled_to_organizations.maestrano_connector_rails_engine.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c13bb79393ae9579e24ece570350fa0c0c75dc9a
|
4
|
+
data.tar.gz: 190acf9ea6c8b0a6cf4eac8d6c3f86edd50b0455
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c971599312170cc42e6754ad7f7e386cc6df2d52fa1c78e5eec880ed5192e1a908c1afbc6be374e251a0912566409b77ac378d4c394528452bea29105ee0212
|
7
|
+
data.tar.gz: 7ad190b146864f5a2c27377d190131cdf11ee308a97c1a65fa82a172659b1fddcc899e02125f66ee52563f8c7873388240ed051d618bb3daa4d8b9f27fef0db7
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.10
|
@@ -9,6 +9,14 @@ module Maestrano::Connector::Rails
|
|
9
9
|
# * :connec_preemption => true|false : preemption is always|never given to connec in case of conflict (if not set, the most recently updated entity is kept)
|
10
10
|
def perform(organization, opts)
|
11
11
|
return unless organization.sync_enabled
|
12
|
+
|
13
|
+
# Check if previous synchronization is still running
|
14
|
+
previous_synchronization = Synchronization.where(organization_id: organization.id).order(created_at: :desc).first
|
15
|
+
if previous_synchronization && previous_synchronization.status == 'RUNNING'
|
16
|
+
ConnectorLogger.log('info', organization, "Previous synchronization is still running")
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
12
20
|
ConnectorLogger.log('info', organization, "Start synchronization, opts=#{opts}")
|
13
21
|
current_synchronization = Synchronization.create_running(organization)
|
14
22
|
|
@@ -85,32 +85,36 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
85
85
|
idmap = mapped_external_entity_with_idmap[:idmap]
|
86
86
|
|
87
87
|
if idmap.connec_id.blank?
|
88
|
-
connec_entity = self.
|
89
|
-
idmap.update_attributes(connec_id: connec_entity['id'], connec_entity: connec_entity_name.downcase, last_push_to_connec: Time.now)
|
88
|
+
connec_entity = self.create_connec_entity(connec_client, external_entity, connec_entity_name, organization)
|
89
|
+
idmap.update_attributes(connec_id: connec_entity['id'], connec_entity: connec_entity_name.downcase, last_push_to_connec: Time.now, message: nil)
|
90
90
|
else
|
91
|
-
connec_entity = self.
|
92
|
-
idmap.update_attributes(last_push_to_connec: Time.now)
|
91
|
+
connec_entity = self.update_connec_entity(connec_client, external_entity, idmap.connec_id, connec_entity_name, organization)
|
92
|
+
idmap.update_attributes(last_push_to_connec: Time.now, message: nil)
|
93
93
|
end
|
94
|
+
|
95
|
+
# Store Connec! error if any
|
96
|
+
idmap.update_attributes(message: connec_entity['errors'].first['title']) unless connec_entity.blank? || connec_entity['errors'].blank?
|
94
97
|
end
|
95
98
|
end
|
96
99
|
|
97
|
-
def
|
100
|
+
def create_connec_entity(connec_client, mapped_external_entity, connec_entity_name, organization)
|
98
101
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending create #{connec_entity_name}: #{mapped_external_entity} to Connec!")
|
99
102
|
response = connec_client.post("/#{connec_entity_name.downcase.pluralize}", { "#{connec_entity_name.downcase.pluralize}".to_sym => mapped_external_entity })
|
100
103
|
raise "No response received from Connec! when trying to create a #{self.connec_entity_name}" unless response
|
101
104
|
JSON.parse(response.body)["#{connec_entity_name.downcase.pluralize}"]
|
102
105
|
end
|
103
106
|
|
104
|
-
def
|
107
|
+
def update_connec_entity(connec_client, mapped_external_entity, connec_id, connec_entity_name, organization)
|
105
108
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending update #{connec_entity_name}: #{mapped_external_entity} to Connec!")
|
106
109
|
response = connec_client.put("/#{connec_entity_name.downcase.pluralize}/#{connec_id}", { "#{connec_entity_name.downcase.pluralize}".to_sym => mapped_external_entity })
|
107
110
|
raise "No response received from Connec! when trying to update a #{self.connec_entity_name}" unless response
|
111
|
+
JSON.parse(response.body)["#{connec_entity_name.downcase.pluralize}"]
|
108
112
|
end
|
109
113
|
|
110
114
|
def map_to_external_with_idmap(entity, organization)
|
111
115
|
idmap = Maestrano::Connector::Rails::IdMap.find_by(connec_id: entity['id'], connec_entity: self.connec_entity_name.downcase, organization_id: organization.id)
|
112
116
|
|
113
|
-
if idmap && idmap.last_push_to_external && idmap.last_push_to_external > entity['updated_at']
|
117
|
+
if idmap && ((!idmap.to_external) || (idmap.last_push_to_external && idmap.last_push_to_external > entity['updated_at']))
|
114
118
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Discard Connec! #{self.connec_entity_name} : #{entity}")
|
115
119
|
nil
|
116
120
|
else
|
@@ -141,21 +145,26 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
141
145
|
idmap = mapped_connec_entity_with_idmap[:idmap]
|
142
146
|
connec_entity = mapped_connec_entity_with_idmap[:entity]
|
143
147
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
148
|
+
begin
|
149
|
+
if idmap.external_id.blank?
|
150
|
+
external_id = self.create_external_entity(external_client, connec_entity, external_entity_name, organization)
|
151
|
+
idmap.update_attributes(external_id: external_id, external_entity: external_entity_name.downcase, last_push_to_external: Time.now, message: nil)
|
152
|
+
else
|
153
|
+
self.update_external_entity(external_client, connec_entity, idmap.external_id, external_entity_name, organization)
|
154
|
+
idmap.update_attributes(last_push_to_external: Time.now, message: nil)
|
155
|
+
end
|
156
|
+
rescue => e
|
157
|
+
# Store External error
|
158
|
+
idmap.update_attributes(message: e.message)
|
150
159
|
end
|
151
160
|
end
|
152
161
|
|
153
|
-
def
|
162
|
+
def create_external_entity(client, mapped_connec_entity, external_entity_name, organization)
|
154
163
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending create #{external_entity_name}: #{mapped_connec_entity} to #{@@external_name}")
|
155
164
|
raise "Not implemented"
|
156
165
|
end
|
157
166
|
|
158
|
-
def
|
167
|
+
def update_external_entity(client, mapped_connec_entity, external_id, external_entity_name, organization)
|
159
168
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending update #{external_entity_name} (id=#{external_id}): #{mapped_connec_entity} to #{@@external_name}")
|
160
169
|
raise "Not implemented"
|
161
170
|
end
|
@@ -183,6 +192,9 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
183
192
|
next {entity: self.map_to_connec(entity, organization), idmap: Maestrano::Connector::Rails::IdMap.create(external_id: self.get_id_from_external_entity_hash(entity), external_entity: self.external_entity_name.downcase, organization_id: organization.id)}
|
184
193
|
end
|
185
194
|
|
195
|
+
# Not pushing entity to Connec!
|
196
|
+
next nil unless idmap.to_connec
|
197
|
+
|
186
198
|
# Entity has not been modified since its last push to connec!
|
187
199
|
if idmap.last_push_to_connec && idmap.last_push_to_connec > self.get_last_update_date_from_external_entity_hash(entity)
|
188
200
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Discard #{@@external_name} #{self.external_entity_name} : #{entity}")
|
@@ -222,14 +234,18 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
222
234
|
# Entity specific methods
|
223
235
|
# Those methods need to be define in each entity
|
224
236
|
# ----------------------------------------------
|
237
|
+
|
238
|
+
# Entity name in Connec!
|
225
239
|
def connec_entity_name
|
226
240
|
raise "Not implemented"
|
227
241
|
end
|
228
242
|
|
243
|
+
# Entity name in external system
|
229
244
|
def external_entity_name
|
230
245
|
raise "Not implemented"
|
231
246
|
end
|
232
247
|
|
248
|
+
# Entity Mapper Class
|
233
249
|
def mapper_class
|
234
250
|
raise "Not implemented"
|
235
251
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class AddNameToIdMap < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :id_maps, :to_connec, :boolean, default: true
|
4
|
+
add_column :id_maps, :to_external, :boolean, default: true
|
5
|
+
add_column :id_maps, :name, :string
|
6
|
+
add_column :id_maps, :message, :string
|
7
|
+
end
|
8
|
+
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: maestrano-connector-rails 0.2.
|
5
|
+
# stub: maestrano-connector-rails 0.2.10 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "maestrano-connector-rails"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.10"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -57,6 +57,7 @@ Gem::Specification.new do |s|
|
|
57
57
|
"db/migrate/20151122163325_create_synchronizations.rb",
|
58
58
|
"db/migrate/20151122163449_create_id_maps.rb",
|
59
59
|
"db/migrate/20160205132857_add_sync_enabled_to_organizations.rb",
|
60
|
+
"db/migrate/20160215103120_add_name_to_id_map.rb",
|
60
61
|
"lib/generators/connector/USAGE",
|
61
62
|
"lib/generators/connector/complex_entity_generator.rb",
|
62
63
|
"lib/generators/connector/install_generator.rb",
|
@@ -127,12 +128,6 @@ Gem::Specification.new do |s|
|
|
127
128
|
"spec/dummy/config/routes.rb",
|
128
129
|
"spec/dummy/config/secrets.yml",
|
129
130
|
"spec/dummy/db/development.sqlite3",
|
130
|
-
"spec/dummy/db/migrate/20160204223447_create_users.maestrano_connector_rails_engine.rb",
|
131
|
-
"spec/dummy/db/migrate/20160204223448_create_organizations.maestrano_connector_rails_engine.rb",
|
132
|
-
"spec/dummy/db/migrate/20160204223449_create_user_organization_rels.maestrano_connector_rails_engine.rb",
|
133
|
-
"spec/dummy/db/migrate/20160204223450_create_synchronizations.maestrano_connector_rails_engine.rb",
|
134
|
-
"spec/dummy/db/migrate/20160204223451_create_id_maps.maestrano_connector_rails_engine.rb",
|
135
|
-
"spec/dummy/db/migrate/20160205133024_add_sync_enabled_to_organizations.maestrano_connector_rails_engine.rb",
|
136
131
|
"spec/dummy/db/schema.rb",
|
137
132
|
"spec/dummy/db/test.sqlite3",
|
138
133
|
"spec/dummy/lib/assets/.keep",
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20160215103120) do
|
15
15
|
|
16
16
|
create_table "id_maps", force: :cascade do |t|
|
17
17
|
t.string "connec_id"
|
@@ -21,8 +21,12 @@ ActiveRecord::Schema.define(version: 20160205133024) do
|
|
21
21
|
t.integer "organization_id"
|
22
22
|
t.datetime "last_push_to_connec"
|
23
23
|
t.datetime "last_push_to_external"
|
24
|
-
t.datetime "created_at",
|
25
|
-
t.datetime "updated_at",
|
24
|
+
t.datetime "created_at", null: false
|
25
|
+
t.datetime "updated_at", null: false
|
26
|
+
t.boolean "to_connec", default: true
|
27
|
+
t.boolean "to_external", default: true
|
28
|
+
t.string "name"
|
29
|
+
t.string "message"
|
26
30
|
end
|
27
31
|
|
28
32
|
add_index "id_maps", ["connec_id", "connec_entity", "organization_id"], name: "idmap_connec_index"
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
data/spec/models/entity_spec.rb
CHANGED
@@ -128,11 +128,11 @@ describe Maestrano::Connector::Rails::Entity do
|
|
128
128
|
let(:id) { 'ab12-34re' }
|
129
129
|
|
130
130
|
it 'create or update the entities and idmaps according to their idmap state' do
|
131
|
-
allow(subject).to receive(:
|
131
|
+
allow(subject).to receive(:create_connec_entity).and_return({'id' => id})
|
132
132
|
allow(subject).to receive(:external_entity_name).and_return(external_name)
|
133
133
|
|
134
|
-
expect(subject).to receive(:
|
135
|
-
expect(subject).to receive(:
|
134
|
+
expect(subject).to receive(:create_connec_entity).with(client, entity2, connec_name, organization)
|
135
|
+
expect(subject).to receive(:update_connec_entity).with(client, entity1, idmap1.connec_id, connec_name, organization)
|
136
136
|
old_push_date = idmap1.last_push_to_connec
|
137
137
|
|
138
138
|
subject.push_entities_to_connec_to(client, entities_with_idmaps, connec_name, organization)
|
@@ -146,7 +146,7 @@ describe Maestrano::Connector::Rails::Entity do
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
-
describe '
|
149
|
+
describe 'create_connec_entity' do
|
150
150
|
let(:entity) { {name: 'John'} }
|
151
151
|
|
152
152
|
describe 'with a response' do
|
@@ -156,11 +156,11 @@ describe Maestrano::Connector::Rails::Entity do
|
|
156
156
|
|
157
157
|
it 'sends a post to connec' do
|
158
158
|
expect(client).to receive(:post).with("/#{connec_name.pluralize}", {"#{connec_name.pluralize}".to_sym => entity})
|
159
|
-
subject.
|
159
|
+
subject.create_connec_entity(client, entity, connec_name, organization)
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'returns the created entity' do
|
163
|
-
expect(subject.
|
163
|
+
expect(subject.create_connec_entity(client, entity, connec_name, organization)).to eql(JSON.parse(entity.to_json))
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
@@ -168,11 +168,11 @@ describe Maestrano::Connector::Rails::Entity do
|
|
168
168
|
before {
|
169
169
|
allow(client).to receive(:post).and_return(nil)
|
170
170
|
}
|
171
|
-
it { expect{ subject.
|
171
|
+
it { expect{ subject.create_connec_entity(client, entity, connec_name, organization) }.to raise_error("No response received from Connec! when trying to create a #{connec_name}") }
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
-
describe '
|
175
|
+
describe 'update_connec_entity' do
|
176
176
|
let(:organization) { create(:organization) }
|
177
177
|
let(:entity) { {name: 'John'} }
|
178
178
|
let(:id) { '88ye-777ab' }
|
@@ -184,7 +184,7 @@ describe Maestrano::Connector::Rails::Entity do
|
|
184
184
|
|
185
185
|
it 'sends a put to connec' do
|
186
186
|
expect(client).to receive(:put).with("/#{connec_name.pluralize}/#{id}", {"#{connec_name.pluralize}".to_sym => entity})
|
187
|
-
subject.
|
187
|
+
subject.update_connec_entity(client, entity, id, connec_name, organization)
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
@@ -192,7 +192,7 @@ describe Maestrano::Connector::Rails::Entity do
|
|
192
192
|
before {
|
193
193
|
allow(client).to receive(:put).and_return(nil)
|
194
194
|
}
|
195
|
-
it { expect{ subject.
|
195
|
+
it { expect{ subject.update_connec_entity(client, entity, id, connec_name, organization) }.to raise_error("No response received from Connec! when trying to update a #{connec_name}") }
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
@@ -273,13 +273,13 @@ describe Maestrano::Connector::Rails::Entity do
|
|
273
273
|
|
274
274
|
describe 'push_entity_to_external' do
|
275
275
|
context 'when the entity idmap has an external id' do
|
276
|
-
it 'calls
|
277
|
-
expect(subject).to receive(:
|
276
|
+
it 'calls update_external_entity' do
|
277
|
+
expect(subject).to receive(:update_external_entity).with(nil, entity1, idmap1.external_id, external_name, organization)
|
278
278
|
subject.push_entity_to_external(nil, entity_with_idmap1, external_name, organization)
|
279
279
|
end
|
280
280
|
|
281
281
|
it 'updates the idmap last push to external' do
|
282
|
-
allow(subject).to receive(:
|
282
|
+
allow(subject).to receive(:update_external_entity)
|
283
283
|
time_before = idmap1.last_push_to_external
|
284
284
|
subject.push_entity_to_external(nil, entity_with_idmap1, external_name, organization)
|
285
285
|
idmap1.reload
|
@@ -288,13 +288,13 @@ describe Maestrano::Connector::Rails::Entity do
|
|
288
288
|
end
|
289
289
|
|
290
290
|
context 'when the entity idmap does not have an external id' do
|
291
|
-
it 'calls
|
292
|
-
expect(subject).to receive(:
|
291
|
+
it 'calls create_external_entity' do
|
292
|
+
expect(subject).to receive(:create_external_entity).with(nil, entity2, external_name, organization)
|
293
293
|
subject.push_entity_to_external(nil, entity_with_idmap2, external_name, organization)
|
294
294
|
end
|
295
295
|
|
296
296
|
it 'updates the idmap external id, entity and last push' do
|
297
|
-
allow(subject).to receive(:
|
297
|
+
allow(subject).to receive(:create_external_entity).and_return('999111')
|
298
298
|
subject.push_entity_to_external(nil, entity_with_idmap2, external_name, organization)
|
299
299
|
idmap2.reload
|
300
300
|
expect(idmap2.external_id).to eql('999111')
|
@@ -304,16 +304,16 @@ describe Maestrano::Connector::Rails::Entity do
|
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
307
|
-
describe '
|
307
|
+
describe 'create_external_entity' do
|
308
308
|
let(:organization) { create(:organization) }
|
309
309
|
|
310
|
-
it { expect{ subject.
|
310
|
+
it { expect{ subject.create_external_entity(nil, nil, nil, organization) }.to raise_error('Not implemented') }
|
311
311
|
end
|
312
312
|
|
313
|
-
describe '
|
313
|
+
describe 'update_external_entity' do
|
314
314
|
let(:organization) { create(:organization) }
|
315
315
|
|
316
|
-
it { expect{ subject.
|
316
|
+
it { expect{ subject.update_external_entity(nil, nil, nil, nil, organization) }.to raise_error('Not implemented') }
|
317
317
|
end
|
318
318
|
|
319
319
|
describe 'get_id_from_external_entity_hash' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maestrano-connector-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Berard
|
@@ -225,6 +225,7 @@ files:
|
|
225
225
|
- db/migrate/20151122163325_create_synchronizations.rb
|
226
226
|
- db/migrate/20151122163449_create_id_maps.rb
|
227
227
|
- db/migrate/20160205132857_add_sync_enabled_to_organizations.rb
|
228
|
+
- db/migrate/20160215103120_add_name_to_id_map.rb
|
228
229
|
- lib/generators/connector/USAGE
|
229
230
|
- lib/generators/connector/complex_entity_generator.rb
|
230
231
|
- lib/generators/connector/install_generator.rb
|
@@ -295,12 +296,6 @@ files:
|
|
295
296
|
- spec/dummy/config/routes.rb
|
296
297
|
- spec/dummy/config/secrets.yml
|
297
298
|
- spec/dummy/db/development.sqlite3
|
298
|
-
- spec/dummy/db/migrate/20160204223447_create_users.maestrano_connector_rails_engine.rb
|
299
|
-
- spec/dummy/db/migrate/20160204223448_create_organizations.maestrano_connector_rails_engine.rb
|
300
|
-
- spec/dummy/db/migrate/20160204223449_create_user_organization_rels.maestrano_connector_rails_engine.rb
|
301
|
-
- spec/dummy/db/migrate/20160204223450_create_synchronizations.maestrano_connector_rails_engine.rb
|
302
|
-
- spec/dummy/db/migrate/20160204223451_create_id_maps.maestrano_connector_rails_engine.rb
|
303
|
-
- spec/dummy/db/migrate/20160205133024_add_sync_enabled_to_organizations.maestrano_connector_rails_engine.rb
|
304
299
|
- spec/dummy/db/schema.rb
|
305
300
|
- spec/dummy/db/test.sqlite3
|
306
301
|
- spec/dummy/lib/assets/.keep
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# This migration comes from maestrano_connector_rails_engine (originally 20151122162100)
|
2
|
-
class CreateUsers < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :users do |t|
|
5
|
-
t.string :provider
|
6
|
-
t.string :uid
|
7
|
-
t.string :first_name
|
8
|
-
t.string :last_name
|
9
|
-
t.string :email
|
10
|
-
t.string :tenant
|
11
|
-
|
12
|
-
t.timestamps null: false
|
13
|
-
end
|
14
|
-
|
15
|
-
add_index :users, [:uid, :tenant], name: 'user_uid_index'
|
16
|
-
end
|
17
|
-
end
|
data/spec/dummy/db/migrate/20160204223448_create_organizations.maestrano_connector_rails_engine.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# This migration comes from maestrano_connector_rails_engine (originally 20151122162414)
|
2
|
-
class CreateOrganizations < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :organizations do |t|
|
5
|
-
t.string :provider
|
6
|
-
t.string :uid
|
7
|
-
t.string :name
|
8
|
-
t.string :tenant
|
9
|
-
|
10
|
-
t.string :oauth_provider
|
11
|
-
t.string :oauth_uid
|
12
|
-
t.string :oauth_token
|
13
|
-
t.string :refresh_token
|
14
|
-
t.string :instance_url
|
15
|
-
|
16
|
-
t.string :synchronized_entities
|
17
|
-
|
18
|
-
t.timestamps null: false
|
19
|
-
end
|
20
|
-
add_index :organizations, [:uid, :tenant], name: 'orga_uid_index'
|
21
|
-
end
|
22
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# This migration comes from maestrano_connector_rails_engine (originally 20151122162613)
|
2
|
-
class CreateUserOrganizationRels < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :user_organization_rels do |t|
|
5
|
-
t.integer :user_id
|
6
|
-
t.integer :organization_id
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
add_index :user_organization_rels, :organization_id, name: 'rels_orga_index'
|
11
|
-
add_index :user_organization_rels, :user_id, name: 'rels_user_index'
|
12
|
-
end
|
13
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# This migration comes from maestrano_connector_rails_engine (originally 20151122163325)
|
2
|
-
class CreateSynchronizations < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :synchronizations do |t|
|
5
|
-
t.integer :organization_id
|
6
|
-
t.string :status
|
7
|
-
t.text :message
|
8
|
-
t.boolean :partial, default: false
|
9
|
-
|
10
|
-
t.timestamps null: false
|
11
|
-
end
|
12
|
-
add_index :synchronizations, :organization_id, name: 'synchronization_orga_id_index'
|
13
|
-
end
|
14
|
-
end
|
data/spec/dummy/db/migrate/20160204223451_create_id_maps.maestrano_connector_rails_engine.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# This migration comes from maestrano_connector_rails_engine (originally 20151122163449)
|
2
|
-
class CreateIdMaps < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :id_maps do |t|
|
5
|
-
t.string :connec_id
|
6
|
-
t.string :connec_entity
|
7
|
-
t.string :external_id
|
8
|
-
t.string :external_entity
|
9
|
-
t.integer :organization_id
|
10
|
-
t.datetime :last_push_to_connec
|
11
|
-
t.datetime :last_push_to_external
|
12
|
-
|
13
|
-
t.timestamps null: false
|
14
|
-
end
|
15
|
-
add_index :id_maps, [:connec_id, :connec_entity, :organization_id], name: 'idmap_connec_index'
|
16
|
-
add_index :id_maps, [:external_id, :external_entity, :organization_id], name: 'idmap_external_index'
|
17
|
-
add_index :id_maps, :organization_id, name: 'idmap_organization_index'
|
18
|
-
end
|
19
|
-
end
|