Add database setup (LosaGame, LosaGame_log, LosaLogData, Backup, backup/restore) and the tested one-PC server config

This commit is contained in:
LosaDev committed 2026-11-07 20:41:23 +07:00
1 parent 224e4bc926
commit 16966077f1
373 files changed
+2411724 -448

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
-- LosaDev 2014: creates LosaGame, LosaGame_log, LosaLogData and Backup (empty). Run first.
-- Backup stays empty: procedures such as game_practice_rank_reward and game_region_backup_point create
-- their own tables in it (SELECT ... INTO [Backup].dbo.<name>), so the game login must own it.
-- sqlcmd -S <server> -E -f 65001 -v DB_COLLATE=DEFAULT -i 00_create_databases.sql
-- DB_COLLATE=DEFAULT = the instance's collation (recommended: install SQL Server with
-- Korean_Wansung_CI_AS so Korean text in varchar columns survives). Otherwise e.g. Korean_Wansung_CI_AS.
USE [master]
GO
DECLARE @c nvarchar(128) = N'$(DB_COLLATE)', @sql nvarchar(max), @db sysname
IF @c = N'DEFAULT' SET @c = N''
DECLARE d CURSOR LOCAL FAST_FORWARD FOR SELECT v FROM (VALUES (N'LosaGame'), (N'LosaGame_log'), (N'LosaLogData'), (N'Backup')) t(v)
OPEN d
FETCH NEXT FROM d INTO @db
WHILE @@FETCH_STATUS = 0
BEGIN
IF DB_ID(@db) IS NULL
BEGIN
SET @sql = N'CREATE DATABASE ' + QUOTENAME(@db) + CASE WHEN LEN(@c) > 0 THEN N' COLLATE ' + @c ELSE N'' END
EXEC (@sql)
PRINT 'created ' + @db
END
ELSE PRINT @db + ' already exists (kept)'
FETCH NEXT FROM d INTO @db
END
CLOSE d
DEALLOCATE d
GO
+16
View File
@@ -0,0 +1,16 @@
-- LosaDev 2014: SQL logins the DB agents use (ID= in each ls_dbagent.ini). The password comes from
-- the DB_PASSWORD variable (setup-db.bat asks for it); put the same value in PW= of the ls_dbagent.ini files.
USE [master]
GO
IF NOT EXISTS (SELECT 1 FROM sys.server_principals WHERE name = N'lstggame')
CREATE LOGIN [lstggame] WITH PASSWORD = N'$(DB_PASSWORD)', CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF, DEFAULT_DATABASE = [master]
ELSE
ALTER LOGIN [lstggame] WITH PASSWORD = N'$(DB_PASSWORD)'
GO
IF NOT EXISTS (SELECT 1 FROM sys.server_principals WHERE name = N'lstgweb')
CREATE LOGIN [lstgweb] WITH PASSWORD = N'$(DB_PASSWORD)', CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF, DEFAULT_DATABASE = [master]
ELSE
ALTER LOGIN [lstgweb] WITH PASSWORD = N'$(DB_PASSWORD)'
GO
ALTER LOGIN [lstgweb] DISABLE
GO
+597
View File
@@ -0,0 +1,597 @@
-- LosaDev 2014: LosaGame_log from the 2021 release (the 2014 release has no script for it; its procedures
-- write log_cash, log_agree, log_play_exec and other tables of this database). CREATE DATABASE block taken out.
USE [master]
GO
/****** Object: Database [LosaGame_log] Script Date: 5/4/2025 8:44:49 PM ******/
-- (LosaDev) CREATE DATABASE [LosaGame_log] is done by 00_create_databases.sql
GO
ALTER DATABASE [LosaGame_log] SET COMPATIBILITY_LEVEL = 160
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [LosaGame_log].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [LosaGame_log] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [LosaGame_log] SET ANSI_NULLS OFF
GO
ALTER DATABASE [LosaGame_log] SET ANSI_PADDING OFF
GO
ALTER DATABASE [LosaGame_log] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [LosaGame_log] SET ARITHABORT OFF
GO
ALTER DATABASE [LosaGame_log] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [LosaGame_log] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [LosaGame_log] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [LosaGame_log] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [LosaGame_log] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [LosaGame_log] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [LosaGame_log] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [LosaGame_log] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [LosaGame_log] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [LosaGame_log] SET DISABLE_BROKER
GO
ALTER DATABASE [LosaGame_log] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [LosaGame_log] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [LosaGame_log] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [LosaGame_log] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [LosaGame_log] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [LosaGame_log] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [LosaGame_log] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [LosaGame_log] SET RECOVERY SIMPLE
GO
ALTER DATABASE [LosaGame_log] SET MULTI_USER
GO
ALTER DATABASE [LosaGame_log] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [LosaGame_log] SET DB_CHAINING OFF
GO
ALTER DATABASE [LosaGame_log] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [LosaGame_log] SET TARGET_RECOVERY_TIME = 60 SECONDS
GO
ALTER DATABASE [LosaGame_log] SET DELAYED_DURABILITY = DISABLED
GO
ALTER DATABASE [LosaGame_log] SET ACCELERATED_DATABASE_RECOVERY = OFF
GO
ALTER DATABASE [LosaGame_log] SET QUERY_STORE = ON
GO
ALTER DATABASE [LosaGame_log] SET QUERY_STORE (OPERATION_MODE = READ_WRITE, CLEANUP_POLICY = (STALE_QUERY_THRESHOLD_DAYS = 30), DATA_FLUSH_INTERVAL_SECONDS = 900, INTERVAL_LENGTH_MINUTES = 60, MAX_STORAGE_SIZE_MB = 1000, QUERY_CAPTURE_MODE = AUTO, SIZE_BASED_CLEANUP_MODE = AUTO, MAX_PLANS_PER_QUERY = 200, WAIT_STATS_CAPTURE_MODE = ON)
GO
USE [LosaGame_log]
GO
/****** Object: User [lstggame] Script Date: 5/4/2025 8:44:49 PM ******/
CREATE USER [lstggame] FOR LOGIN [lstggame] WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Object: Table [dbo].[log_cash] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_cash](
[idx] [int] IDENTITY(1,1) NOT NULL,
[accountIDX] [int] NOT NULL,
[userIP] [varchar](16) NOT NULL,
[DBID] [varchar](16) NOT NULL,
[applyType] [char](2) NOT NULL,
[amount] [int] NOT NULL,
[note] [varchar](500) NOT NULL,
[regDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_class_buytime] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_class_buytime](
[idx] [int] IDENTITY(1,1) NOT NULL,
[classType] [int] NOT NULL,
[buyTime] [bigint] NOT NULL,
[regDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_class_rental_history] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_class_rental_history](
[idx] [int] IDENTITY(1,1) NOT NULL,
[accountIDX] [int] NOT NULL,
[friendIDX] [int] NOT NULL,
[classType] [int] NOT NULL,
[regDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_data_clover] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_data_clover](
[idx] [int] IDENTITY(1,1) NOT NULL,
[accountIDX] [int] NOT NULL,
[friendIDX] [int] NOT NULL,
[eventType] [smallint] NOT NULL,
[CloverCount] [int] NOT NULL,
[regDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Index [index] Script Date: 5/4/2025 8:44:49 PM ******/
CREATE CLUSTERED INDEX [index] ON [dbo].[log_data_clover]
(
[idx] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_event_marble] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_event_marble](
[idx] [int] IDENTITY(1,1) NOT NULL,
[accountidx] [int] NOT NULL,
[userID] [varchar](20) NOT NULL,
[cpType] [int] NOT NULL,
[regDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_event_openbeta_coin] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_event_openbeta_coin](
[idx] [int] IDENTITY(1,1) NOT NULL,
[accountIDX] [int] NOT NULL,
[coin] [int] NOT NULL,
[flag] [int] NOT NULL,
[regDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_guild_mark] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_guild_mark](
[idx] [int] IDENTITY(1,1) NOT NULL,
[guildIDX] [int] NOT NULL,
[accountIDX] [int] NOT NULL,
[havepeso] [bigint] NOT NULL,
[markprice] [int] NOT NULL,
[nowmark] [int] NOT NULL,
[changemark] [int] NOT NULL,
[flag] [int] NOT NULL,
[userIP] [varchar](15) NULL,
[regDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_league_cheer] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_league_cheer](
[idx] [int] IDENTITY(1,1) NOT NULL,
[cheerIDX] [int] NOT NULL,
[startDate] [int] NOT NULL,
[accountIDX] [int] NOT NULL,
[leagueIDX] [int] NOT NULL,
[teamIDX] [int] NOT NULL,
[regDate] [datetime] NOT NULL,
[insertDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_league_info_user] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_league_info_user](
[idx] [int] IDENTITY(1,1) NOT NULL,
[infoIDX] [int] NULL,
[leagueIDX] [int] NULL,
[leagueName] [nvarchar](20) NULL,
[maxRound] [smallint] NULL,
[bannerA] [int] NULL,
[bannerB] [int] NULL,
[modeType] [int] NULL,
[maxcount] [tinyint] NULL,
[autoType] [tinyint] NULL,
[announce] [nvarchar](512) NULL,
[recruitDate] [int] NULL,
[waitDate] [int] NULL,
[regDate] [datetime] NULL,
[insertDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_league_list] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_league_list](
[idx] [int] IDENTITY(1,1) NOT NULL,
[leagueIDX] [int] NULL,
[accountIDX] [int] NULL,
[startDate] [int] NULL,
[endDate] [int] NULL,
[leagueType] [tinyint] NULL,
[leagueState] [tinyint] NULL,
[regDate] [datetime] NULL,
[insertDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_league_list_user] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_league_list_user](
[idx] [int] IDENTITY(1,1) NOT NULL,
[leagueIDX] [int] NULL,
[accountIDX] [int] NULL,
[startDate] [int] NULL,
[endDate] [int] NULL,
[leagueType] [tinyint] NULL,
[leagueState] [tinyint] NULL,
[regDate] [datetime] NULL,
[insertDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_league_round_user] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_league_round_user](
[idx] [int] IDENTITY(1,1) NOT NULL,
[roundIDX] [int] NULL,
[infoIDX] [int] NULL,
[roundType1_playDate] [int] NULL,
[roundType1_presentCode1] [int] NULL,
[roundType1_presentCode2] [int] NULL,
[roundType1_presentCode3] [int] NULL,
[roundType1_presentCode4] [int] NULL,
[roundType2_playDate] [int] NULL,
[roundType2_presentCode1] [int] NULL,
[roundType2_presentCode2] [int] NULL,
[roundType2_presentCode3] [int] NULL,
[roundType2_presentCode4] [int] NULL,
[roundType3_playDate] [int] NULL,
[roundType3_presentCode1] [int] NULL,
[roundType3_presentCode2] [int] NULL,
[roundType3_presentCode3] [int] NULL,
[roundType3_presentCode4] [int] NULL,
[roundType4_playDate] [int] NULL,
[roundType4_presentCode1] [int] NULL,
[roundType4_presentCode2] [int] NULL,
[roundType4_presentCode3] [int] NULL,
[roundType4_presentCode4] [int] NULL,
[roundType5_playDate] [int] NULL,
[roundType5_presentCode1] [int] NULL,
[roundType5_presentCode2] [int] NULL,
[roundType5_presentCode3] [int] NULL,
[roundType5_presentCode4] [int] NULL,
[roundType6_playDate] [int] NULL,
[roundType6_presentCode1] [int] NULL,
[roundType6_presentCode2] [int] NULL,
[roundType6_presentCode3] [int] NULL,
[roundType6_presentCode4] [int] NULL,
[roundType7_playDate] [int] NULL,
[roundType7_presentCode1] [int] NULL,
[roundType7_presentCode2] [int] NULL,
[roundType7_presentCode3] [int] NULL,
[roundType7_presentCode4] [int] NULL,
[roundType8_playDate] [int] NULL,
[roundType8_presentCode1] [int] NULL,
[roundType8_presentCode2] [int] NULL,
[roundType8_presentCode3] [int] NULL,
[roundType8_presentCode4] [int] NULL,
[roundType9_playDate] [int] NULL,
[roundType9_presentCode1] [int] NULL,
[roundType9_presentCode2] [int] NULL,
[roundType9_presentCode3] [int] NULL,
[roundType9_presentCode4] [int] NULL,
[roundType10_playDate] [int] NULL,
[roundType10_presentCode1] [int] NULL,
[roundType10_presentCode2] [int] NULL,
[roundType10_presentCode3] [int] NULL,
[roundType10_presentCode4] [int] NULL,
[roundType11_playDate] [int] NULL,
[roundType11_presentCode1] [int] NULL,
[roundType11_presentCode2] [int] NULL,
[roundType11_presentCode3] [int] NULL,
[roundType11_presentCode4] [int] NULL,
[regDate] [datetime] NULL,
[insertDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_league_team] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_league_team](
[idx] [int] IDENTITY(1,1) NOT NULL,
[teamIDX] [int] NULL,
[leagueIDX] [int] NULL,
[startDate] [int] NULL,
[teamName] [nvarchar](20) NULL,
[leaderIDX] [int] NULL,
[leagueStartPosition] [smallint] NULL,
[leaguePosition] [smallint] NULL,
[maxcount] [tinyint] NULL,
[cheerPoint] [int] NULL,
[currentRound] [tinyint] NULL,
[factionPoint] [int] NULL,
[factionType] [tinyint] NULL,
[regDate] [datetime] NULL,
[insertDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_league_team_member] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_league_team_member](
[idx] [int] IDENTITY(1,1) NOT NULL,
[teamMemberIDX] [int] NULL,
[startDate] [int] NULL,
[accountIDX] [int] NULL,
[leagueIDX] [int] NULL,
[teamIDX] [int] NULL,
[joinType] [tinyint] NULL,
[regDate] [datetime] NULL,
[insertDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_league_team_member_user] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_league_team_member_user](
[idx] [int] IDENTITY(1,1) NOT NULL,
[teamMemberIDX] [int] NOT NULL,
[startDate] [int] NOT NULL,
[accountIDX] [int] NOT NULL,
[leagueIDX] [int] NOT NULL,
[teamIDX] [int] NOT NULL,
[joinType] [tinyint] NOT NULL,
[regDate] [datetime] NOT NULL,
[insertDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_league_team_user] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_league_team_user](
[idx] [int] IDENTITY(1,1) NOT NULL,
[teamIDX] [int] NULL,
[leagueIDX] [int] NULL,
[startDate] [int] NULL,
[teamName] [nvarchar](20) NULL,
[leaderIDX] [int] NULL,
[leagueStartPosition] [smallint] NULL,
[leaguePosition] [smallint] NULL,
[maxcount] [tinyint] NULL,
[cheerPoint] [int] NULL,
[currentRound] [tinyint] NULL,
[factionPoint] [int] NULL,
[factionType] [tinyint] NULL,
[regDate] [datetime] NULL,
[insertDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_level_playtime] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_level_playtime](
[idx] [int] IDENTITY(1,1) NOT NULL,
[userLevel] [int] NOT NULL,
[playTime] [bigint] NOT NULL,
[regDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_mannerpoint] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_mannerpoint](
[idx] [int] IDENTITY(1,1) NOT NULL,
[playType] [int] NOT NULL,
[modeType] [int] NOT NULL,
[sub1Type] [int] NOT NULL,
[sub2Type] [int] NOT NULL,
[reportIDX] [int] NULL,
[reportNick] [varchar](20) NULL,
[reportpubIP] [varchar](15) NOT NULL,
[reportpriIP] [varchar](15) NOT NULL,
[receiveIDX] [nchar](10) NULL,
[receiveNick] [varchar](20) NULL,
[receivepubIP] [varchar](15) NOT NULL,
[roomInfo] [varchar](2000) NULL,
[chatInfo] [varchar](3000) NULL,
[note] [varchar](500) NULL,
[reason] [varchar](2000) NULL,
[flag] [tinyint] NOT NULL,
[resultType] [tinyint] NOT NULL,
[regDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_mannerpoint_sitevisit] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_mannerpoint_sitevisit](
[idx] [int] IDENTITY(1,1) NOT NULL,
[accountIDX] [int] NOT NULL,
[point] [smallint] NOT NULL,
[userIP] [varchar](15) NOT NULL,
[regDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[log_tooni_migration] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[log_tooni_migration](
[idx] [int] IDENTITY(1,1) NOT NULL,
[TooniIDX] [int] NOT NULL,
[TooniID] [varchar](32) NOT NULL,
[AccountIDX] [int] NOT NULL,
[RegDate] [datetime] NOT NULL,
CONSTRAINT [PK_log_tooni_migration] PRIMARY KEY CLUSTERED
(
[RegDate] ASC,
[idx] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Index [accountidx] Script Date: 5/4/2025 8:44:49 PM ******/
CREATE NONCLUSTERED INDEX [accountidx] ON [dbo].[log_data_clover]
(
[accountIDX] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
/****** Object: Index [regDate] Script Date: 5/4/2025 8:44:49 PM ******/
CREATE NONCLUSTERED INDEX [regDate] ON [dbo].[log_data_clover]
(
[regDate] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
/****** Object: Index [NC_log_tooni_migration_AccountIDX] Script Date: 5/4/2025 8:44:49 PM ******/
CREATE NONCLUSTERED INDEX [NC_log_tooni_migration_AccountIDX] ON [dbo].[log_tooni_migration]
(
[AccountIDX] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object: Index [NC_log_tooni_migration_TooniID] Script Date: 5/4/2025 8:44:49 PM ******/
CREATE NONCLUSTERED INDEX [NC_log_tooni_migration_TooniID] ON [dbo].[log_tooni_migration]
(
[TooniID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
ALTER TABLE [dbo].[log_class_buytime] ADD CONSTRAINT [DF_log_class_buytime_classType] DEFAULT ((0)) FOR [classType]
GO
ALTER TABLE [dbo].[log_class_buytime] ADD CONSTRAINT [DF_log_class_buytime_buyTime] DEFAULT ((0)) FOR [buyTime]
GO
ALTER TABLE [dbo].[log_class_buytime] ADD CONSTRAINT [DF_log_class_buytime_regDate] DEFAULT (getdate()) FOR [regDate]
GO
ALTER TABLE [dbo].[log_class_rental_history] ADD CONSTRAINT [DF_log_class_rental_history_classType] DEFAULT ((0)) FOR [classType]
GO
ALTER TABLE [dbo].[log_class_rental_history] ADD CONSTRAINT [DF_log_class_rental_history_regDate] DEFAULT (getdate()) FOR [regDate]
GO
ALTER TABLE [dbo].[log_data_clover] ADD CONSTRAINT [DF_log_clover_friendIdx] DEFAULT ((0)) FOR [friendIDX]
GO
ALTER TABLE [dbo].[log_data_clover] ADD CONSTRAINT [DF_log_clover_regDate] DEFAULT (getdate()) FOR [regDate]
GO
ALTER TABLE [dbo].[log_event_marble] ADD CONSTRAINT [DF_log_event_marble_regDate] DEFAULT (getdate()) FOR [regDate]
GO
ALTER TABLE [dbo].[log_event_openbeta_coin] ADD CONSTRAINT [DF_log_event_openbeta_coin_flag] DEFAULT ((0)) FOR [flag]
GO
ALTER TABLE [dbo].[log_event_openbeta_coin] ADD CONSTRAINT [DF_log_event_openbeta_coin_regDate] DEFAULT (getdate()) FOR [regDate]
GO
ALTER TABLE [dbo].[log_guild_mark] ADD CONSTRAINT [DF_log_guild_mark_flag] DEFAULT ((0)) FOR [flag]
GO
ALTER TABLE [dbo].[log_guild_mark] ADD CONSTRAINT [DF_log_guild_mark_regDate] DEFAULT (getdate()) FOR [regDate]
GO
ALTER TABLE [dbo].[log_league_cheer] ADD CONSTRAINT [DF_log_league_cheer_insertDate] DEFAULT (getdate()) FOR [insertDate]
GO
ALTER TABLE [dbo].[log_league_info_user] ADD CONSTRAINT [DF_log_league_info_user_insertDate] DEFAULT (getdate()) FOR [insertDate]
GO
ALTER TABLE [dbo].[log_league_list] ADD CONSTRAINT [DF_log_league_list_insertDate] DEFAULT (getdate()) FOR [insertDate]
GO
ALTER TABLE [dbo].[log_league_list_user] ADD CONSTRAINT [DF_log_league_list_user_insertDate] DEFAULT (getdate()) FOR [insertDate]
GO
ALTER TABLE [dbo].[log_league_round_user] ADD CONSTRAINT [DF_log_league_round_user_insertDate] DEFAULT (getdate()) FOR [insertDate]
GO
ALTER TABLE [dbo].[log_league_team] ADD CONSTRAINT [DF_log_league_team_leagueStartPosition] DEFAULT ((0)) FOR [leagueStartPosition]
GO
ALTER TABLE [dbo].[log_league_team] ADD CONSTRAINT [DF_log_league_team_insertDate] DEFAULT (getdate()) FOR [insertDate]
GO
ALTER TABLE [dbo].[log_league_team_member] ADD CONSTRAINT [DF_log_league_team_member_insertDate] DEFAULT (getdate()) FOR [insertDate]
GO
ALTER TABLE [dbo].[log_league_team_member_user] ADD CONSTRAINT [DF_log_league_team_member_user_insertDate] DEFAULT (getdate()) FOR [insertDate]
GO
ALTER TABLE [dbo].[log_league_team_user] ADD CONSTRAINT [DF_log_league_team_user_insertDate] DEFAULT (getdate()) FOR [insertDate]
GO
ALTER TABLE [dbo].[log_level_playtime] ADD CONSTRAINT [DF_log_level_playtime_userLevel] DEFAULT ((0)) FOR [userLevel]
GO
ALTER TABLE [dbo].[log_level_playtime] ADD CONSTRAINT [DF_log_level_playtime_playTime] DEFAULT ((0)) FOR [playTime]
GO
ALTER TABLE [dbo].[log_level_playtime] ADD CONSTRAINT [DF_log_level_playtime_regDate] DEFAULT (getdate()) FOR [regDate]
GO
ALTER TABLE [dbo].[log_mannerpoint] ADD CONSTRAINT [DF_log_mannerpoint_flag] DEFAULT ((0)) FOR [flag]
GO
ALTER TABLE [dbo].[log_mannerpoint] ADD CONSTRAINT [DF_log_mannerpoint_resultType] DEFAULT ((0)) FOR [resultType]
GO
ALTER TABLE [dbo].[log_tooni_migration] ADD DEFAULT (getdate()) FOR [RegDate]
GO
/****** Object: StoredProcedure [dbo].[game_item_etc_get_self_index] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[game_item_etc_get_self_index]
(
@accountIDX int
)
AS
SELECT TOP 1 idx FROM userItemEtcDB WHERE accountIDX = @accountIDX ORDER BY idx DESC
GO
/****** Object: StoredProcedure [dbo].[log_data_clover_add] Script Date: 5/4/2025 8:44:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create PROCEDURE [dbo].[log_data_clover_add]
(
@userIDX int
, @FriendIDX int
, @Type smallint
, @Count int
)
AS
SET NOCOUNT ON
-- 클로버 정보가 없을때 insert
INSERT INTO dbo.log_data_clover( accountIDX, friendIDX, eventType, CloverCount, regDate )
VALUES( @userIDX, @FriendIDX, @Type, @Count, GETDATE() );
GO
USE [master]
GO
ALTER DATABASE [LosaGame_log] SET READ_WRITE
GO
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+129
View File
@@ -0,0 +1,129 @@
-- LosaDev 2014: src\sql\20120504\lostsaga_etc.sql as UTF-8 (functions, users). One old view fails; expected.
USE [LosaGame]
GO
/****** 개체: User [lstggame] 스크립트 날짜: 05/04/2012 14:09:58 ******/
CREATE USER [lstggame] FOR LOGIN [lstggame] WITH DEFAULT_SCHEMA=[dbo]
GO
/****** 개체: User [lstgweb] 스크립트 날짜: 05/04/2012 14:09:58 ******/
CREATE USER [lstgweb] FOR LOGIN [lstgweb] WITH DEFAULT_SCHEMA=[dbo]
GO
/****** 개체: UserDefinedFunction [dbo].[DEFINE_REGION_LIMIT_SE_RENSPOINT] 스크립트 날짜: 05/04/2012 14:09:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[DEFINE_REGION_LIMIT_SE_RENSPOINT]
(
)
RETURNS int
As
BEGIN
DECLARE @returnVal int
SET @returnVal = 5
RETURN @returnVal
END
GO
/****** 개체: UserDefinedFunction [dbo].[DEFINE_REGION_LIMIT_RENSPOINT] 스크립트 날짜: 05/04/2012 14:09:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[DEFINE_REGION_LIMIT_RENSPOINT]
(
)
RETURNS int
As
BEGIN
DECLARE @returnVal int
SET @returnVal = 5
RETURN @returnVal
END
GO
/****** 개체: UserDefinedFunction [dbo].[DEFINE_SERVER_CONNECTION_MAX_COUNT] 스크립트 날짜: 05/04/2012 14:09:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[DEFINE_SERVER_CONNECTION_MAX_COUNT]
(
)
RETURNS int
AS
BEGIN
DECLARE @maxcount int
SET @maxcount = 2500
RETURN @maxcount
END
GO
/****** 개체: View [dbo].[userMannerpointDB] 스크립트 날짜: 05/04/2012 14:09:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[userMannerpointDB]
AS
SELECT receiveIDX as 'accountIDX', receivepoint as 'point', reportpubIP as 'userIP', regDate FROM LosaGame_log.DBO.log_mannerpoint
UNION ALL
SELECT accountIDX, point, userIP, regDate FROM LosaGame_log.DBO.log_mannerpoint_sitevisit
GO
/****** 개체: View [dbo].[userQuestView] 스크립트 날짜: 05/04/2012 14:09:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[userQuestView] AS
SELECT * FROM (
SELECT idx, accountIDX, 1 as pos, quest1_type as quest_type, quest1_value1 as quest_value1, quest1_value2 as quest_value2, quest1_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 2 as pos, quest2_type as quest_type, quest2_value1 as quest_value1, quest2_value2 as quest_value2, quest2_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 3 as pos, quest3_type as quest_type, quest3_value1 as quest_value1, quest3_value2 as quest_value2, quest3_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 4 as pos, quest4_type as quest_type, quest4_value1 as quest_value1, quest4_value2 as quest_value2, quest4_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 5 as pos, quest5_type as quest_type, quest5_value1 as quest_value1, quest5_value2 as quest_value2, quest5_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 6 as pos, quest6_type as quest_type, quest6_value1 as quest_value1, quest6_value2 as quest_value2, quest6_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 7 as pos, quest7_type as quest_type, quest7_value1 as quest_value1, quest7_value2 as quest_value2, quest7_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 8 as pos, quest8_type as quest_type, quest8_value1 as quest_value1, quest8_value2 as quest_value2, quest8_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 9 as pos, quest9_type as quest_type, quest9_value1 as quest_value1, quest9_value2 as quest_value2, quest9_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 10 as pos, quest10_type as quest_type, quest10_value1 as quest_value1, quest10_value2 as quest_value2, quest10_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 11 as pos, quest11_type as quest_type, quest11_value1 as quest_value1, quest11_value2 as quest_value2, quest11_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 12 as pos, quest12_type as quest_type, quest12_value1 as quest_value1, quest12_value2 as quest_value2, quest12_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 13 as pos, quest13_type as quest_type, quest13_value1 as quest_value1, quest13_value2 as quest_value2, quest13_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 14 as pos, quest14_type as quest_type, quest14_value1 as quest_value1, quest14_value2 as quest_value2, quest14_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 15 as pos, quest15_type as quest_type, quest15_value1 as quest_value1, quest15_value2 as quest_value2, quest15_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 16 as pos, quest16_type as quest_type, quest16_value1 as quest_value1, quest16_value2 as quest_value2, quest16_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 17 as pos, quest17_type as quest_type, quest17_value1 as quest_value1, quest17_value2 as quest_value2, quest17_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 18 as pos, quest18_type as quest_type, quest18_value1 as quest_value1, quest18_value2 as quest_value2, quest18_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 19 as pos, quest19_type as quest_type, quest19_value1 as quest_value1, quest19_value2 as quest_value2, quest19_time as quest_time FROM userQuestDB WITH (nolock)
UNION ALL
SELECT idx, accountIDX, 20 as pos, quest20_type as quest_type, quest20_value1 as quest_value1, quest20_value2 as quest_value2, quest20_time as quest_time FROM userQuestDB WITH (nolock)
) as a
WHERE quest_type <> 0
GO
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+59
View File
@@ -0,0 +1,59 @@
-- LosaDev 2014: fixes for the 2014 servers on top of the May 2012 scripts, plus test accounts.
USE [LosaGame];
GO
-- 1. The 2014 game server sends its 64-bit server ID (query 3), the 2012 procedure expected the row index.
ALTER PROCEDURE [dbo].[game_server_connection_on]
(
@serverID bigint
)
AS
UPDATE define_game_server SET [status] = 1 WHERE serverID = @serverID
GO
-- 2. Second encryption key (query 5, game_encode_get_fix_key). The login key's ID part is encrypted
-- with it. Shorter than 16 characters.
IF NOT EXISTS (SELECT * FROM define_encode_key)
INSERT INTO define_encode_key (encodeKey, regDate) VALUES ('$(ENCODE_KEY)', getdate());
GO
-- 3. Test accounts. The game server (Korea mode) checks userMemberDB.userID + userLoginDB.encodeKey;
-- there is no password check on the server: the launcher/web normally writes a fresh encodeKey
-- and passes it to the client (tools\start-client.ps1 does that here).
CREATE PROCEDURE [dbo].[lshub_add_test_account]
(
@userID varchar(12)
, @nickName varchar(20)
)
AS
SET NOCOUNT ON
IF EXISTS (SELECT * FROM userMemberDB WHERE userID = @userID) RETURN
INSERT INTO userMemberDB (userID, nickName, userPWD, EMail, mailling, userType, joinType, limitType, limitDate, regDate)
VALUES (@userID, @nickName, '', '', 0, 0, 0, 0, '1999-01-01', getdate())
DECLARE @accountIDX int = (SELECT accountIDX FROM userMemberDB WHERE userID = @userID)
INSERT INTO userGameDB (accountIDX, userState, gameMoney, playTime, conn_count, userLevel, userEXP, rencpoint, renspoint, relateLevel, regionType, connDate, regDate)
VALUES (@accountIDX, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '2000-01-01', getdate())
INSERT INTO userRecordBattleDB (accountIDX, regDate) VALUES (@accountIDX, getdate())
INSERT INTO userLoginDB (accountIDX, encodeKey, gameServerID, connDate) VALUES (@accountIDX, '111111111111111', 0, getdate())
GO
-- Resets the login key before a client start (what the web login did). Returns the key.
CREATE PROCEDURE [dbo].[lshub_set_login_key]
(
@userID varchar(12)
, @encodeKey char(15)
)
AS
SET NOCOUNT ON
UPDATE userLoginDB SET encodeKey = @encodeKey, gameServerID = 0, connDate = getdate()
WHERE accountIDX = (SELECT accountIDX FROM userMemberDB WHERE userID = @userID)
SELECT encodeKey, (SELECT TOP 1 encodeKey FROM define_encode_key ORDER BY idx DESC) AS secondKey
FROM userLoginDB WHERE accountIDX = (SELECT accountIDX FROM userMemberDB WHERE userID = @userID)
GO
EXEC lshub_add_test_account 'test1', 'Tester1';
EXEC lshub_add_test_account 'test2', 'Tester2';
-- GM: the game server treats a nickname that starts with an [ID_LIKE] prefix from
-- ls_gamesvr\config\sp2_developerID.ini (here "[GM]") as a developer.
EXEC lshub_add_test_account 'gmtest1', '[GM]Admin';
GO
+84
View File
@@ -0,0 +1,84 @@
-- LosaDev 2014: procedures whose 2012 parameter list is shorter than what the 2014 game server sends
-- ("has too many arguments specified"). The extra parameters get defaults; behaviour otherwise unchanged.
USE [LosaGame];
GO
-- query 22: the 2014 server pages the gear list (last index, account, page size)
ALTER PROCEDURE [dbo].[game_item_extra_get_list]
(
@lastIndex int
, @accountIDX int = 0
, @pageSize int = 0
)
AS
SET NOCOUNT ON
SELECT TOP (CASE WHEN @pageSize > 0 THEN @pageSize ELSE 2147483647 END) idx
, item1_type, item1_reinforce, item1_slotindex, item1_tradetype, item1_limitType, item1_mcustom, item1_fcustom, item1_limitDate
, item2_type, item2_reinforce, item2_slotindex, item2_tradetype, item2_limitType, item2_mcustom, item2_fcustom, item2_limitDate
, item3_type, item3_reinforce, item3_slotindex, item3_tradetype, item3_limitType, item3_mcustom, item3_fcustom, item3_limitDate
, item4_type, item4_reinforce, item4_slotindex, item4_tradetype, item4_limitType, item4_mcustom, item4_fcustom, item4_limitDate
, item5_type, item5_reinforce, item5_slotindex, item5_tradetype, item5_limitType, item5_mcustom, item5_fcustom, item5_limitDate
, item6_type, item6_reinforce, item6_slotindex, item6_tradetype, item6_limitType, item6_mcustom, item6_fcustom, item6_limitDate
, item7_type, item7_reinforce, item7_slotindex, item7_tradetype, item7_limitType, item7_mcustom, item7_fcustom, item7_limitDate
, item8_type, item8_reinforce, item8_slotindex, item8_tradetype, item8_limitType, item8_mcustom, item8_fcustom, item8_limitDate
, item9_type, item9_reinforce, item9_slotindex, item9_tradetype, item9_limitType, item9_mcustom, item9_fcustom, item9_limitDate
, item10_type, item10_reinforce, item10_slotindex, item10_tradetype, item10_limitType, item10_mcustom, item10_fcustom, item10_limitDate
FROM userItemExtraDB WHERE accountIDX = @accountIDX AND idx > @lastIndex ORDER BY idx
GO
-- query 26: same paging for the decoration item list (last index, account, page size)
ALTER PROCEDURE [dbo].[game_item_get_data_list]
(
@lastIndex int
, @accountIDX int = 0
, @pageSize int = 0
)
AS
SET NOCOUNT ON
SELECT TOP (CASE WHEN @pageSize > 0 THEN @pageSize ELSE 2147483647 END)
idx, item1_type, item1_code, item2_type, item2_code, item3_type, item3_code,
item4_type, item4_code, item5_type, item5_code, item6_type, item6_code,
item7_type, item7_code, item8_type, item8_code, item9_type, item9_code,
item10_type, item10_code, item11_type, item11_code, item12_type, item12_code,
item13_type, item13_code, item14_type, item14_code, item15_type, item15_code,
item16_type, item16_code, item17_type, item17_code, item18_type, item18_code,
item19_type, item19_code, item20_type, item20_code
FROM userItemDB WHERE accountIDX = @accountIDX AND idx > @lastIndex ORDER BY idx
GO
-- query 12: the 2014 server adds the relative grade init code as 15th value (not stored here)
ALTER PROCEDURE [dbo].[game_game_save]
(
@accountIDX int
, @userState int
, @gameMoney bigint
, @conn_count int
, @connDate datetime
, @userLevel int
, @userEXP int
, @playTime int
, @regionType int
, @userFishingLevel int
, @userFishingEXP int
, @refillData int
, @userExcavationLevel int
, @userExcavationEXP int
, @relativeInitCode int = 0
)
AS
UPDATE userGameDB SET
gameMoney = @gameMoney
, userState = @userState
, playTime = playTime + Round((@playTime/1000)/60,0)
, conn_count = @conn_count
, userLevel = @userLevel
, userEXP = @userEXP
, userFishingLevel = @userFishingLevel
, userFishingEXP = @userFishingEXP
, regionType = @regionType
, connDate = @connDate
, refillData = @refillData
, userExcavationLevel = @userExcavationLevel
, userExcavationEXP = @userExcavationEXP
WHERE accountIDX = @accountIDX
GO
File diff suppressed because it is too large. Load diff
+21
View File
@@ -0,0 +1,21 @@
-- First regular tournament (Faction War / LS Cup panel). The main server only continues a row that exists;
-- nothing creates the first one. leagueType 1 = TYPE_REGULAR, leagueState 1 = STATE_TEAM_APP, accountIDX 0 = no owner.
-- Dates are YYMMDDHHMM in a DWORD (Help::ConvertCTimeToDate). Since 2022 that is above the int range, so the
-- int columns hold the wrapped value; the server reads the same bits back as a DWORD.
-- Starts on the last Monday 03:00 and runs next_tournament_hour (336) hours, like sp2_tournament_regular.ini.
USE [LosaGame]
GO
IF NOT EXISTS (SELECT 1 FROM dbo.userLeagueListDB WHERE leagueType = 1)
BEGIN
DECLARE @s datetime, @e datetime, @a bigint, @b bigint
SET @s = DATEADD(hour, 3, DATEADD(day, -(DATEDIFF(day, 0, GETDATE()) % 7), DATEDIFF(day, 0, GETDATE())))
SET @e = DATEADD(hour, 336, @s)
SET @a = CAST(YEAR(@s) % 100 AS bigint) * 100000000 + MONTH(@s) * 1000000 + DAY(@s) * 10000 + DATEPART(hour, @s) * 100
SET @b = CAST(YEAR(@e) % 100 AS bigint) * 100000000 + MONTH(@e) * 1000000 + DAY(@e) * 10000 + DATEPART(hour, @e) * 100
IF @a > 2147483647 SET @a = @a - 4294967296
IF @b > 2147483647 SET @b = @b - 4294967296
INSERT INTO dbo.userLeagueListDB (accountIDX, startDate, endDate, leagueType, leagueState, regDate)
VALUES (0, @a, @b, 1, 1, GETDATE())
END
SELECT idx, startDate, endDate, leagueType, leagueState FROM dbo.userLeagueListDB
GO
+266
View File
@@ -0,0 +1,266 @@
-- Generated. Real tables and procedures from the 2021 release for features that were stubs in the 2014 testbed.
USE [LosaGame]
GO
IF OBJECT_ID('dbo.game_character_get_list') IS NOT NULL DROP PROCEDURE dbo.game_character_get_list
GO
CREATE PROCEDURE [dbo].[game_character_get_list]
(
@accountIDX INT
)
AS
SET NOCOUNT ON
SELECT idx, ClassType,
CI_type, CI_gender, CI_beard, CI_face, CI_hair, CI_skinColor, CI_hairColor, CI_trinket, CI_underwear,
EI1_type, EI2_type, EI3_type, EI4_type, CI_position,
limitTime, limitType, leaderType, rentalType, rentalTime, awakeType, awakeTime
FROM dbo.userCharacterDB WITH(NOLOCK)
WHERE accountIDX = @accountIDX
ORDER BY idx ASC
GO
IF OBJECT_ID('dbo.game_class_get_list') IS NOT NULL DROP PROCEDURE dbo.game_class_get_list
GO
CREATE PROCEDURE [dbo].[game_class_get_list]
(
@accountIDX INT
)
AS
SET NOCOUNT ON
SELECT idx,
class1_type, class1_level, class1_expert, class1_stat, class2_type, class2_level, class2_expert, class2_stat,
class3_type, class3_level, class3_expert, class3_stat, class4_type, class4_level, class4_expert, class4_stat,
class5_type, class5_level, class5_expert, class5_stat, class6_type, class6_level, class6_expert, class6_stat,
class7_type, class7_level, class7_expert, class7_stat, class8_type, class8_level, class8_expert, class8_stat,
class9_type, class9_level, class9_expert, class9_stat, class10_type, class10_level, class10_expert, class10_stat
FROM dbo.userClassDB WITH(NOLOCK)
WHERE accountIDX = @accountIDX
ORDER BY idx ASC
GO
IF OBJECT_ID('dbo.game_game_get_data') IS NOT NULL DROP PROCEDURE dbo.game_game_get_data
GO
CREATE PROCEDURE [dbo].[game_game_get_data]
(
@userID varchar(12)
)
As
SET NOCOUNT ON
DECLARE @CURRENTDATE DATETIME
DECLARE @CONNECTDATE DATETIME
SET @CURRENTDATE = GETDATE();
SET @CONNECTDATE = ( SELECT conndate FROM dbo.userGameDB WHERE accountIDX IN ( SELECT accountIDX FROM dbo.userMemberDB WHERE userID = @userID ))
BEGIN
IF( @CURRENTDATE < @CONNECTDATE )
SET @CONNECTDATE = @CURRENTDATE
END
SELECT a.accountIDX, b.userID, b.nickName, a.userState, a.gameMoney
, a.conn_count, @CONNECTDATE, a.userLevel, a.userEXP--, a.relateLevel
, b.eventType, isNull(c.class,0) as 'class', b.joinType, b.regDate, a.regionType
, a.rencpoint, a.renspoint, isNull(c.region,0) as 'region', b.cpType, ISNULL(d.cpID, '') AS 'cpID'
, ISNULL(d.note, '') AS 'cpUNIQ', b.limitType, b.limitDate, a.userFishingLevel, a.userFishingEXP
, a.refillData, a.userExcavationLevel, a.userExcavationEXP, a.userHerocEXP, a.userHerosEXP, a.practice
FROM userGameDB a WITH( NOLOCK )
JOIN userMemberDB b WITH( NOLOCK )
ON a.accountIDX = b.accountIDX
LEFT JOIN userRankingDB c WITH( NOLOCK )
ON a.accountIDX = c.accountIDX
LEFT JOIN userCooperationDB d WITH( NOLOCK )
ON a.accountIDX=d.accountIDX WHERE b.userID = @userID
GO
IF OBJECT_ID('dbo.game_game_save') IS NOT NULL DROP PROCEDURE dbo.game_game_save
GO
CREATE PROCEDURE [dbo].[game_game_save]
(
@accountIDX int
, @userState int
, @gameMoney bigint
, @conn_count int
, @connDate datetime
, @userLevel int
, @userEXP int
, @playTime int
, @regionType int
, @userFishingLevel int
, @userFishingEXP int
, @refillData int
, @userExcavationLevel int
, @userExcavationEXP int
, @init_time int
)
As
SET NOCOUNT ON
IF @userLevel < 50
BEGIN
-- 기존 루틴 그대로
UPDATE dbo.userGameDB
SET gameMoney = @gameMoney
, userState = @userState
, playTime = playTime + Round((@playTime/1000)/60,0)
, conn_count = @conn_count
, userLevel = @userLevel
, userEXP = @userEXP
, userFishingLevel = @userFishingLevel
, userFishingEXP = @userFishingEXP
, regionType = @regionType
, connDate = @connDate
, refillData = @refillData
, userExcavationLevel = @userExcavationLevel
, userExcavationEXP = @userExcavationEXP
, Practice = 0
WHERE accountIDX = @accountIDX
END
ELSE
BEGIN
--
IF( EXISTS( SELECT * FROM dbo.userRelativeLevelDB WITH( NOLOCK )
WHERE accountIDX = @accountIDX ) )
BEGIN
UPDATE dbo.userGameDB
SET gameMoney = @gameMoney
, userState = @userState
, playTime = playTime + Round((@playTime/1000)/60,0)
, conn_count = @conn_count
--, userLevel = @userLevel
, userEXP = @userEXP
, userFishingLevel = @userFishingLevel
, userFishingEXP = @userFishingEXP
, regionType = @regionType
, connDate = @connDate
, refillData = @refillData
, userExcavationLevel = @userExcavationLevel
, userExcavationEXP = @userExcavationEXP
, Practice = 0
WHERE accountIDX = @accountIDX
UPDATE dbo.userRelativeLevelDB
SET init_time = @init_time
WHERE accountIDX = @accountIDX
END
ELSE
BEGIN
-- 기존 루틴 그대로 : 혹시나 ?
UPDATE dbo.userGameDB
SET gameMoney = @gameMoney
, userState = @userState
, playTime = playTime + Round((@playTime/1000)/60,0)
, conn_count = @conn_count
, userLevel = @userLevel
, userEXP = @userEXP
, userFishingLevel = @userFishingLevel
, userFishingEXP = @userFishingEXP
, regionType = @regionType
, connDate = @connDate
, refillData = @refillData
, userExcavationLevel = @userExcavationLevel
, userExcavationEXP = @userExcavationEXP
, Practice = 0
WHERE accountIDX = @accountIDX
END
END
GO
IF OBJECT_ID('dbo.game_item_extra_get_list') IS NOT NULL DROP PROCEDURE dbo.game_item_extra_get_list
GO
CREATE PROCEDURE [dbo].[game_item_extra_get_list]
(
@idx INT
, @accountIDX INT
, @getCount int
)
AS
SET NOCOUNT ON
SELECT TOP (@getCount) idx,
item1_type, item1_reinforce, item1_slotindex, item1_tradetype, item1_limitType, item1_mcustom, item1_fcustom, item1_failexp, item1_limitDate,
item2_type, item2_reinforce, item2_slotindex, item2_tradetype, item2_limitType, item2_mcustom, item2_fcustom, item2_failexp, item2_limitDate,
item3_type, item3_reinforce, item3_slotindex, item3_tradetype, item3_limitType, item3_mcustom, item3_fcustom, item3_failexp, item3_limitDate,
item4_type, item4_reinforce, item4_slotindex, item4_tradetype, item4_limitType, item4_mcustom, item4_fcustom, item4_failexp, item4_limitDate,
item5_type, item5_reinforce, item5_slotindex, item5_tradetype, item5_limitType, item5_mcustom, item5_fcustom, item5_failexp, item5_limitDate,
item6_type, item6_reinforce, item6_slotindex, item6_tradetype, item6_limitType, item6_mcustom, item6_fcustom, item6_failexp, item6_limitDate,
item7_type, item7_reinforce, item7_slotindex, item7_tradetype, item7_limitType, item7_mcustom, item7_fcustom, item7_failexp, item7_limitDate,
item8_type, item8_reinforce, item8_slotindex, item8_tradetype, item8_limitType, item8_mcustom, item8_fcustom, item8_failexp, item8_limitDate,
item9_type, item9_reinforce, item9_slotindex, item9_tradetype, item9_limitType, item9_mcustom, item9_fcustom, item9_failexp, item9_limitDate,
item10_type, item10_reinforce, item10_slotindex, item10_tradetype, item10_limitType, item10_mcustom, item10_fcustom, item10_failexp, item10_limitDate
FROM dbo.userItemExtraDB WITH (NOLOCK)
WHERE accountIDX = @accountIDX
AND idx > @idx
ORDER BY idx ASC
GO
IF OBJECT_ID('dbo.game_guild_login_get_data') IS NOT NULL DROP PROCEDURE dbo.game_guild_login_get_data
GO
-- =============================================
-- Subject : dbo.game_guild_login_get_data
-- DBA : KeuN
-- DATE : 2015-08-24 09:43
-- Description : 길드원 데이터 SELECT (길드본부 추가)
-- =============================================
CREATE PROCEDURE [dbo].[game_guild_login_get_data]
(
@ACCOUNT_IDX int
)
AS
SET NOCOUNT ON
DECLARE @GUILD_IDX INT = 0;
DECLARE @GUILD_HQ TINYINT = 0;
-- 길드 본부 활성화 여부 확인
SET @GUILD_IDX = (SELECT guildIDX FROM dbo.userGuildInfoDB WHERE AccountIDX=@ACCOUNT_IDX)
IF (@GUILD_IDX<>0) or (@GUILD_IDX IS NOT NULL)
BEGIN
IF EXISTS (SELECT * FROM dbo.userGuildHQDB WHERE GuildIDX=@GUILD_IDX)
BEGIN
SET @GUILD_HQ=1
END
END
-- 사용자 길드 관련 데이터 세팅
SELECT B.idx, B.guildName, B.guildmark, A.guildPosition, A.msg, A.AttendDate, A.GuildRankDate, A.regDate, @GUILD_HQ
FROM dbo.userGuildInfoDB as A WITH(READUNCOMMITTED) INNER JOIN dbo.userGuildDB AS B WITH(READUNCOMMITTED)
ON A.guildIDX = B.idx
WHERE A.accountIDX = @ACCOUNT_IDX
AND A.guildJoinType in (-1, 1)
GO
IF OBJECT_ID('dbo.game_guild_get_list') IS NOT NULL DROP PROCEDURE dbo.game_guild_get_list
GO
CREATE PROCEDURE [dbo].[game_guild_get_list]
(
@topn int
, @idx int
)
AS
SET NOCOUNT ON
SELECT TOP (@topn) a.idx, a.guildName, a.aboutguild, a.guildmark, a.point, a.maxcount, a.regDate,
a.membercount, a.todaypoint, a.guildLevel,
b.type1_win, b.type1_lose, b.type1_kill, b.type1_death
FROM dbo.userGuildDB a WITH(NOLOCK)
INNER JOIN dbo.userRecordGuildDB b WITH(NOLOCK)
ON a.idx = b.guildIDX
WHERE a.idx < @idx
ORDER BY a.idx DESC
GO
USE [LosaGame]
GO
-- game_friend_list_asc names this index in a table hint; the 2012 table does not have it.
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name='idx_userAccIDX' AND object_id=OBJECT_ID('dbo.userFriendDB'))
CREATE CLUSTERED INDEX idx_userAccIDX ON dbo.userFriendDB (userAccIDX)
GO
+21
View File
@@ -0,0 +1,21 @@
-- LosaDev 2014: database users for the DB agent logins (db_owner, like the original service).
USE [LosaGame_log]
GO
IF USER_ID(N'lstggame') IS NULL CREATE USER [lstggame] FOR LOGIN [lstggame]
ALTER ROLE [db_owner] ADD MEMBER [lstggame]
GO
USE [Backup]
GO
IF USER_ID(N'lstggame') IS NULL CREATE USER [lstggame] FOR LOGIN [lstggame]
ALTER ROLE [db_owner] ADD MEMBER [lstggame]
GO
USE [LosaLogData]
GO
IF USER_ID(N'lstggame') IS NULL CREATE USER [lstggame] FOR LOGIN [lstggame]
ALTER ROLE [db_owner] ADD MEMBER [lstggame]
GO
USE [LosaGame]
GO
IF USER_ID(N'lstggame') IS NULL CREATE USER [lstggame] FOR LOGIN [lstggame]
ALTER ROLE [db_owner] ADD MEMBER [lstggame]
GO
+60
View File
@@ -0,0 +1,60 @@
# Database setup (2014)
Creates the four databases the 2014 servers use, with the original names:
| Database | Used by |
|---|---|
| `LosaGame` | game data and accounts (DB agent `ls_dbagent_game`) |
| `LosaGame_log` | logs written by procedures in `LosaGame` |
| `LosaLogData` | log server (DB agent `ls_dbagent_log`); only procedures, the log queries are stubs |
| `Backup` | stays empty: `game_region_backup_point` / `game_region_backup_compen` create their own tables in it |
This is the set used by the tested local setup (2026-11-07: nine servers, three accounts reach the lobby and the headquarters tutorial).
## Expected messages
Tested on SQL Server 2022 Express. Every script runs clean except two that come from the May 2012 base scripts:
- `04_LosaGame_procs.sql`: 153 "Invalid column name" messages = 22 old procedures written for newer tables. None of them is called by the 2014 servers.
- `05_LosaGame_etc.sql`: one old view (`userMannerpointDB`) fails the same way.
`LosaGame_log` comes from the 2021 release (the 2014 release has no script for it). 8 of the 23 log tables the old 2012 procedures write exist there; the other 15 belong to the old publisher web site (real-name check, recommend events, parent consent). 33 procedures use them and none is called by the servers (`ls_query.ini`), so nothing in game is affected.
## Needs
- SQL Server 2019 or newer (Express is enough) with **SQL Server and Windows authentication** (mixed mode).
- `sqlcmd` on PATH.
- Recommended: instance collation `Korean_Wansung_CI_AS`, like the original service.
## Setup
```bat
setup-db.bat .\SQLEXPRESS
```
It asks for the **DB agent password** (SQL login `lstggame`, used by both DB agents) and the **encode key** (15 characters, stored as the second key row; the login key tool must use the same value). Logs go to `logs\`.
**The 2014 DB agents expect the password encoded**: run `ls_dbagent.exe -x <password>` and put its output in `PW=` of both `ls_dbagent.ini` files. A disabled login `lstgweb` is also created only because the 2012 script creates a user for it.
| Script | Does |
|---|---|
| `00_create_databases.sql` | creates `LosaGame`, `LosaGame_log`, `LosaLogData`, `Backup` |
| `01_logins.sql` | SQL login `lstggame` (and the disabled `lstgweb`) |
| `02_LosaGame_log.sql` | `LosaGame_log` tables from the 2021 release |
| `03`-`05` | the 2014 release's `src\sql\20120504` scripts (tables, procedures, functions), UTF-8 |
| `06_LosaGame_stubs.sql`, `07_LosaLogData_stubs.sql` | empty stand-in procedures for the queries in `ls_query.ini` the 2012 scripts do not have (about 175 in LosaGame); replace one with a real procedure to make that feature work |
| `08_fixes_and_accounts.sql` | 64-bit server ID, the encode key, test accounts `test1`, `test2`, `gmtest1`, the login-key helper |
| `09_param_fixes.sql` | procedures whose 2012 parameter list is shorter than what the 2014 server sends |
| `10_features_from_2021.sql`, `12_core_procs_from_2021.sql` | columns, tables and procedures from the 2021 release that 2014 features need (pets, faction, costumes, ...) |
| `11_first_tournament.sql` | the first tournament row |
| `13_users.sql` | `lstggame` becomes `db_owner` of all four databases |
| `optional\test-heroes.sql` | six permanent heroes for the test accounts (Savage Berserker first: the headquarters tutorial needs it) |
## Backup and restore
```bat
backup.bat D:\LosaBackup .\SQLEXPRESS
restore.bat 20261107_1400 D:\LosaBackup .\SQLEXPRESS
```
`backup.bat` writes `<database>_<yyyyMMdd_HHmm>.bak` for all four databases (online). `restore.bat` asks first and replaces all four: **stop every server before restoring**. It restores to the paths stored in the backup (same server); on another server use `RESTORE DATABASE ... WITH MOVE` by hand.
+9
View File
@@ -0,0 +1,9 @@
@echo off
rem LosaDev 2014: backup.bat [folder] [server] (defaults: D:\LosaBackup, .\SQLEXPRESS)
setlocal
set DIR=%~1
if "%DIR%"=="" set DIR=D:\LosaBackup
set SRV=%~2
if "%SRV%"=="" set SRV=.\SQLEXPRESS
if not exist "%DIR%" mkdir "%DIR%"
sqlcmd -S "%SRV%" -E -b -v BACKUP_DIR="%DIR%" -i "%~dp0backup.sql"
+26
View File
@@ -0,0 +1,26 @@
-- LosaDev 2014: full backup of LosaGame, LosaGame_log, LosaLogData and Backup.
-- sqlcmd -S <server> -E -v BACKUP_DIR="D:\LosaBackup" -i backup.sql (or backup.bat)
-- One file per database: <db>_yyyyMMdd_HHmm.bak in BACKUP_DIR (the folder must exist and the SQL
-- Server service account needs write access). Online backup: the servers may keep running.
USE [master]
GO
SET NOCOUNT ON
DECLARE @dir nvarchar(400) = N'$(BACKUP_DIR)', @stamp nvarchar(20) = FORMAT(GETDATE(), 'yyyyMMdd_HHmm'), @db sysname, @file nvarchar(600)
IF RIGHT(@dir, 1) = N'\' SET @dir = LEFT(@dir, LEN(@dir) - 1)
DECLARE d CURSOR LOCAL FAST_FORWARD FOR SELECT v FROM (VALUES (N'LosaGame'), (N'LosaGame_log'), (N'LosaLogData'), (N'Backup')) t(v)
OPEN d
FETCH NEXT FROM d INTO @db
WHILE @@FETCH_STATUS = 0
BEGIN
IF DB_ID(@db) IS NOT NULL
BEGIN
SET @file = @dir + N'\' + @db + N'_' + @stamp + N'.bak'
BACKUP DATABASE @db TO DISK = @file WITH INIT, CHECKSUM, STATS = 25
PRINT 'backup ' + @db + ' -> ' + @file
END
ELSE PRINT 'skip ' + @db + ' (does not exist)'
FETCH NEXT FROM d INTO @db
END
CLOSE d
DEALLOCATE d
GO
+29
View File
@@ -0,0 +1,29 @@
-- Test heroes for the three test accounts. A new account owns no hero, so the game opens with a
-- "no hero available" popup. Six permanent heroes each (limitType 1 = CPT_MORTMAIN). Class 6, Savage
-- Berserker, comes first and is the leader (leaderType 1): the headquarters tutorial is written for
-- that hero and gets stuck with another one. Same columns as game_character_add. Safe to run
-- again: accounts that already own a hero are skipped.
USE [LosaGame]
GO
DECLARE @acc int
DECLARE acc CURSOR LOCAL FAST_FORWARD FOR
SELECT accountIDX FROM dbo.userMemberDB m
WHERE m.userID IN ('test1', 'test2', 'gmtest1')
AND NOT EXISTS (SELECT 1 FROM dbo.userCharacterDB c WHERE c.accountIDX = m.accountIDX)
OPEN acc
FETCH NEXT FROM acc INTO @acc
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO dbo.userCharacterDB (accountIDX, ClassType, CI_type, CI_gender, CI_beard, CI_face, CI_hair, CI_skinColor, CI_hairColor, CI_trinket, CI_underwear, CI_position, EI1_type, EI2_type, EI3_type, EI4_type, limitTime, limitType, leaderType, rentalType, rentalTime)
SELECT @acc, h.class, 1, 1, 1, 1, 1, 1, 1, 1, 1, h.pos, 0, 0, 0, 0, 0, 1, CASE WHEN h.class = 6 THEN 1 ELSE 0 END, 0, 0
FROM (VALUES (6, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)) AS h(class, pos)
ORDER BY h.pos
-- Tutorial set = class type * 100 (User::_OnLeaderCreate). Skills only count when the hero's gear
-- set matches it, so the tutorial must be the Savage set.
UPDATE dbo.userGameDB SET userState = 600 WHERE accountIDX = @acc
FETCH NEXT FROM acc INTO @acc
END
CLOSE acc
DEALLOCATE acc
SELECT m.userID, COUNT(c.idx) AS heroes FROM dbo.userMemberDB m LEFT JOIN dbo.userCharacterDB c ON c.accountIDX = m.accountIDX GROUP BY m.userID
GO
+12
View File
@@ -0,0 +1,12 @@
@echo off
rem LosaDev 2014: restore.bat <stamp> [folder] [server] stamp = yyyyMMdd_HHmm of the backup files
rem Stop every game server first. The three databases are replaced.
setlocal
if "%~1"=="" echo Usage: restore.bat ^<yyyyMMdd_HHmm^> [folder] [server] & exit /b 1
set DIR=%~2
if "%DIR%"=="" set DIR=D:\LosaBackup
set SRV=%~3
if "%SRV%"=="" set SRV=.\SQLEXPRESS
choice /m "Replace LosaGame, LosaGame_log, LosaLogData and Backup on %SRV% with the %~1 backup"
if errorlevel 2 exit /b 1
sqlcmd -S "%SRV%" -E -b -v BACKUP_DIR="%DIR%" STAMP="%~1" -i "%~dp0restore.sql"
+30
View File
@@ -0,0 +1,30 @@
-- LosaDev 2014: restores LosaGame, LosaGame_log, LosaLogData and Backup from backup.sql files.
-- sqlcmd -S <server> -E -v BACKUP_DIR="D:\LosaBackup" STAMP="20261107_1400" -i restore.sql (or restore.bat)
-- STAMP = the yyyyMMdd_HHmm part of the file names. STOP ALL GAME SERVERS FIRST: each database is
-- set to single user and replaced. The files go back to the paths stored in the backup, so restore
-- on the same server; on another server use RESTORE ... WITH MOVE by hand (see README.md).
USE [master]
GO
SET NOCOUNT ON
DECLARE @dir nvarchar(400) = N'$(BACKUP_DIR)', @stamp nvarchar(20) = N'$(STAMP)', @db sysname, @file nvarchar(600), @sql nvarchar(400)
IF RIGHT(@dir, 1) = N'\' SET @dir = LEFT(@dir, LEN(@dir) - 1)
DECLARE d CURSOR LOCAL FAST_FORWARD FOR SELECT v FROM (VALUES (N'LosaGame'), (N'LosaGame_log'), (N'LosaLogData'), (N'Backup')) t(v)
OPEN d
FETCH NEXT FROM d INTO @db
WHILE @@FETCH_STATUS = 0
BEGIN
SET @file = @dir + N'\' + @db + N'_' + @stamp + N'.bak'
IF DB_ID(@db) IS NOT NULL
BEGIN
SET @sql = N'ALTER DATABASE ' + QUOTENAME(@db) + N' SET SINGLE_USER WITH ROLLBACK IMMEDIATE'
EXEC (@sql)
END
RESTORE DATABASE @db FROM DISK = @file WITH REPLACE, CHECKSUM
SET @sql = N'ALTER DATABASE ' + QUOTENAME(@db) + N' SET MULTI_USER'
EXEC (@sql)
PRINT 'restored ' + @db + ' from ' + @file
FETCH NEXT FROM d INTO @db
END
CLOSE d
DEALLOCATE d
GO
+35
View File
@@ -0,0 +1,35 @@
@echo off
rem LosaDev 2014: creates LosaGame, LosaGame_log, LosaLogData and Backup and fills them.
rem Usage: setup-db.bat [server] (default .\SQLEXPRESS; Windows login with sysadmin rights)
rem Needs sqlcmd (SQL Server command line tools) on PATH. Asks for the DB agent password.
rem Logs go to logs\. Existing databases are kept; scripts that already ran give "already exists" errors.
setlocal
cd /d "%~dp0"
set SRV=%~1
if "%SRV%"=="" set SRV=.\SQLEXPRESS
if "%DB_COLLATE%"=="" set DB_COLLATE=DEFAULT
set /p DB_PASSWORD=Password for the DB agent logins (same as PW= in ls_dbagent.ini):
set /p ENCODE_KEY=Encode key, 15 characters:
if "%DB_PASSWORD%"=="" echo No password given. & exit /b 1
if not exist logs mkdir logs
call :run 00_create_databases.sql
call :run 01_logins.sql
call :run 02_LosaGame_log.sql
call :run 03_LosaGame_tables.sql
call :run 04_LosaGame_procs.sql
call :run 05_LosaGame_etc.sql
call :run 06_LosaGame_stubs.sql
call :run 07_LosaLogData_stubs.sql
call :run 08_fixes_and_accounts.sql
call :run 09_param_fixes.sql
call :run 10_features_from_2021.sql
call :run 11_first_tournament.sql
call :run 12_core_procs_from_2021.sql
call :run 13_users.sql
findstr /b /c:"Msg " logs\*.log >nul && (echo Some statements failed: search logs\*.log for "Msg ".) || echo Done, no errors.
exit /b 0
:run
echo running %1
sqlcmd -S "%SRV%" -E -I -f 65001 -v DB_COLLATE="%DB_COLLATE%" DB_PASSWORD="%DB_PASSWORD%" ENCODE_KEY="%ENCODE_KEY%" -i "%1" -o "logs\%~n1.log"
exit /b 0