-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathScript.PostDeployment.sql
More file actions
63 lines (55 loc) · 1.85 KB
/
Script.PostDeployment.sql
File metadata and controls
63 lines (55 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- Create application user
if (serverproperty('Edition') = 'SQL Azure') begin
if not exists (select * from sys.database_principals where [type] in ('E', 'S') and [name] = 'todo_dab_user')
begin
create user [todo_dab_user] with password = 'rANd0m_PAzzw0rd!'
end
alter role db_owner add member [todo_dab_user]
end else begin
if not exists (select * from sys.server_principals where [type] in ('E', 'S') and [name] = 'todo_dab_user')
begin
create login [todo_dab_user] with password = 'rANd0m_PAzzw0rd!'
end
if not exists (select * from sys.database_principals where [type] in ('E', 'S') and [name] = 'todo_dab_user')
begin
create user [todo_dab_user] from login [todo_dab_user]
end
alter role db_owner add member [todo_dab_user]
end
-- Insert sample data
delete from dbo.todos where id in
(
'00000000-0000-0000-0000-000000000001',
'00000000-0000-0000-0000-000000000002',
'00000000-0000-0000-0000-000000000003',
'00000000-0000-0000-0000-000000000004',
'00000000-0000-0000-0000-000000000005'
);
insert into dbo.todos
(
[id],
[title],
[completed],
[owner_id],
[position]
)
values
('00000000-0000-0000-0000-000000000001', N'Hello world', 0, 'public', 1),
('00000000-0000-0000-0000-000000000002', N'This is done', 1, 'public', 2),
('00000000-0000-0000-0000-000000000003', N'And this is not done (yet!)', 0, 'public', 4),
('00000000-0000-0000-0000-000000000004', N'This is a ☆☆☆☆☆ tool!', 0, 'public', 3),
('00000000-0000-0000-0000-000000000005', N'Add support for sorting', 1, 'public', 5)
;
if (object_id('tempdb..#todos_order') is not null)
begin
update
t
set
t.position = s.[order]
from
dbo.todos t
inner join
#todos_order s on t.id = s.id
;
drop table #todos_order;
end